7 #include <nlohmann/detail/input/position_t.hpp>
8 #include <nlohmann/detail/macro_scope.hpp>
50 JSON_HEDLEY_RETURNS_NON_NULL
51 const char*
what() const noexcept
override
60 JSON_HEDLEY_NON_NULL(3)
61 exception(
int id_, const
char* what_arg) :
id(id_), m(what_arg) {}
63 static std::string name(
const std::string& ename,
int id_)
65 return "[json.exception." + ename +
"." + std::to_string(id_) +
"] ";
132 std::string w = exception::name(
"parse_error", id_) +
"parse error" +
133 position_string(pos) +
": " + what_arg;
137 static parse_error create(
int id_, std::size_t byte_,
const std::string& what_arg)
139 std::string w = exception::name(
"parse_error", id_) +
"parse error" +
140 (byte_ != 0 ? (
" at byte " + std::to_string(byte_)) :
"") +
157 parse_error(
int id_, std::size_t byte_,
const char* what_arg)
160 static std::string position_string(
const position_t& pos)
162 return " at line " + std::to_string(pos.
lines_read + 1) +
209 std::string w = exception::name(
"invalid_iterator", id_) + what_arg;
214 JSON_HEDLEY_NON_NULL(3)
261 static type_error create(
int id_,
const std::string& what_arg)
263 std::string w = exception::name(
"type_error", id_) + what_arg;
268 JSON_HEDLEY_NON_NULL(3)
308 static out_of_range create(
int id_,
const std::string& what_arg)
310 std::string w = exception::name(
"out_of_range", id_) + what_arg;
315 JSON_HEDLEY_NON_NULL(3)
346 static other_error create(
int id_,
const std::string& what_arg)
348 std::string w = exception::name(
"other_error", id_) + what_arg;
353 JSON_HEDLEY_NON_NULL(3)
general exception of the basic_json class
Definition: exceptions.hpp:47
const int id
the id of the exception
Definition: exceptions.hpp:57
JSON_HEDLEY_RETURNS_NON_NULL const char * what() const noexcept override
returns the explanatory string
Definition: exceptions.hpp:51
exception indicating errors with iterators
Definition: exceptions.hpp:205
exception indicating other library errors
Definition: exceptions.hpp:344
exception indicating access out of the defined range
Definition: exceptions.hpp:306
exception indicating a parse error
Definition: exceptions.hpp:119
static parse_error create(int id_, const position_t &pos, const std::string &what_arg)
create a parse error exception
Definition: exceptions.hpp:130
const std::size_t byte
byte index of the parse error
Definition: exceptions.hpp:154
exception indicating executing a member function with a wrong type
Definition: exceptions.hpp:259
namespace for Niels Lohmann
Definition: adl_serializer.hpp:9
struct to capture the start position of the current token
Definition: position_t.hpp:11
std::size_t lines_read
the number of lines read
Definition: position_t.hpp:17
std::size_t chars_read_current_line
the number of characters read in the current line
Definition: position_t.hpp:15
std::size_t chars_read_total
the total number of characters read
Definition: position_t.hpp:13