]>
Commit | Line | Data |
---|---|---|
1e59de90 TL |
1 | # <small>nlohmann::basic_json::</small>other_error |
2 | ||
3 | ```cpp | |
4 | class other_error : public exception; | |
5 | ``` | |
6 | ||
7 | This exception is thrown in case of errors that cannot be classified with the other exception types. | |
8 | ||
9 | Exceptions have ids 5xx (see [list of other errors](../../home/exceptions.md#further-exceptions)). | |
10 | ||
11 | ```plantuml | |
12 | std::exception <|-- basic_json::exception | |
13 | basic_json::exception <|-- basic_json::parse_error | |
14 | basic_json::exception <|-- basic_json::invalid_iterator | |
15 | basic_json::exception <|-- basic_json::type_error | |
16 | basic_json::exception <|-- basic_json::out_of_range | |
17 | basic_json::exception <|-- basic_json::other_error | |
18 | ||
19 | interface std::exception {} | |
20 | ||
21 | class basic_json::exception { | |
22 | + const int id | |
23 | + const char* what() const | |
24 | } | |
25 | ||
26 | class basic_json::parse_error { | |
27 | + const std::size_t byte | |
28 | } | |
29 | ||
30 | class basic_json::other_error #FFFF00 {} | |
31 | ``` | |
32 | ||
33 | ## Member functions | |
34 | ||
35 | - **what** - returns explanatory string | |
36 | ||
37 | ## Member variables | |
38 | ||
39 | - **id** - the id of the exception | |
40 | ||
41 | ## Examples | |
42 | ||
43 | ??? example | |
44 | ||
45 | The following code shows how a `other_error` exception can be caught. | |
46 | ||
47 | ```cpp | |
48 | --8<-- "examples/other_error.cpp" | |
49 | ``` | |
50 | ||
51 | Output: | |
52 | ||
53 | ```json | |
54 | --8<-- "examples/other_error.output" | |
55 | ``` | |
56 | ||
57 | ## See also | |
58 | ||
59 | - [List of other errors](../../home/exceptions.md#further-exceptions) | |
60 | - [`parse_error`](parse_error.md) for exceptions indicating a parse error | |
61 | - [`invalid_iterator`](invalid_iterator.md) for exceptions indicating errors with iterators | |
62 | - [`type_error`](type_error.md) for exceptions indicating executing a member function with a wrong type | |
63 | - [`out_of_range`](out_of_range.md) for exceptions indicating access out of the defined range | |
64 | ||
65 | ## Version history | |
66 | ||
67 | - Since version 3.0.0. |