8000 Proposal: Use standard library exceptions · Issue #99 · s-yata/marisa-trie · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Proposal: Use standard library exceptions #99
Open
@glebm

Description

@glebm

I'd like to propose using standard exceptions rather than custom ones in the next major release.

Marisa exception Standard equivalent
MARISA_STATE_ERROR std::logic_error
MARISA_NULL_ERROR std::invalid_argument
MARISA_BOUND_ERROR std::out_of_range
MARISA_RANGE_ERROR std::out_of_range
MARISA_CODE_ERROR std::invalid_argument
MARISA_RESET_ERROR unused
MARISA_SIZE_ERROR std::length_error
MARISA_MEMORY_ERROR std::bad_alloc
MARISA_IO_ERROR std::system_error
MARISA_FORMAT_ERROR std::runtime_error or std::invalid_argument

Benefits:

  1. Marisa code can use the standard library directly (no need for std::nothrow or wrappers such as State: Use std::vector #97).
  2. Some of these exceptions provide more information, e.g. std::system_error carries a system error code.
  3. Plays nicely with global handlers, such as an std::bad_alloc handler.

Drawbacks:

  1. Marisa exceptions carry a file and line number in the message. However, this is a file/line number in the Marisa library rather than the user's code (not that helpful when debugging compared to a stack trace).
  2. Backwards incompatible.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0