1# basic_json::parse_error 2 3```cpp 4class parse_error : public exception; 5``` 6 7This exception is thrown by the library when a parse error occurs. Parse errors can occur during the deserialization of 8JSON text, BSON, CBOR, MessagePack, UBJSON, as well as when using JSON Patch. 9 10Exceptions have ids 1xx. 11 12```plantuml 13std::exception <|-- basic_json::exception 14basic_json::exception <|-- basic_json::parse_error 15basic_json::exception <|-- basic_json::invalid_iterator 16basic_json::exception <|-- basic_json::type_error 17basic_json::exception <|-- basic_json::out_of_range 18basic_json::exception <|-- basic_json::other_error 19 20interface std::exception {} 21 22class basic_json::exception { 23 + const int id 24 + const char* what() const 25} 26 27class basic_json::parse_error #FFFF00 { 28 + const std::size_t byte 29} 30``` 31 32## Member functions 33 34- **what** - returns explanatory string 35 36## Member variables 37 38- **id** - the id of the exception 39- **byte** - byte index of the parse error 40 41## Note 42 43For an input with _n_ bytes, 1 is the index of the first character and _n_+1 is the index of the terminating null byte 44or the end of file. This also holds true when reading a byte vector for binary formats. 45 46## Example 47 48??? example 49 50 The following code shows how a `parse_error` exception can be caught. 51 52 ```cpp 53 --8<-- "examples/parse_error.cpp" 54 ``` 55 56 Output: 57 58 ```json 59 --8<-- "examples/parse_error.output" 60 ``` 61 62## Version history 63 64- Since version 3.0.0. 65