Open
Description
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:
- Marisa code can use the standard library directly (no need for
std::nothrow
or wrappers such as State: Usestd::vector
#97). - Some of these exceptions provide more information, e.g.
std::system_error
carries a system error code. - Plays nicely with global handlers, such as an
std::bad_alloc
handler.
Drawbacks:
- 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).
- Backwards incompatible.
Metadata
Metadata
Assignees
Labels
No labels