Class hierarchy of the library's exceptions; arrows point from a derived class to its base class, and the highlighted box is `basic_json::exception`.
Subclasses: - [`parse_error`](parse_error.md) for exceptions indicating a parse error - [`invalid_iterator`](invalid_iterator.md) for exceptions indicating errors with iterators - [`type_error`](type_error.md) for exceptions indicating executing a member function with a wrong type - [`out_of_range`](out_of_range.md) for exceptions indicating access out of the defined range - [`other_error`](other_error.md) for exceptions indicating other library errors ## Member functions - **what** - returns explanatory string ## Member variables - **id** - the id of the exception ## Notes To have nothrow-copy-constructible exceptions, we internally use `std::runtime_error` which can cope with arbitrary-length error messages. Intermediate strings are built with static functions and then passed to the actual constructor. ## Examples ??? example The following code shows how arbitrary library exceptions can be caught. ```cpp --8<-- "examples/exception.cpp" ``` Output: ```json --8<-- "examples/exception.output" ``` ## See also - [List of exceptions](../../home/exceptions.md) - overview of all exceptions thrown by the library - [Working Without Exceptions](../../features/no_exceptions.md) - using the library without exceptions - [`JSON_DIAGNOSTICS`](../macros/json_diagnostics.md) - extended exception messages with the path of the failing value - [Parsing and Exceptions](../../features/parsing/parse_exceptions.md) - parsing alternatives that do not throw - [Debugging](../../home/debugging.md) - debugging aids ## Version history - Added in version 3.0.0.