34 json_exception::json_exception(
exception_type et) noexcept : exception(), m_type(et)
38 case invalid_json_type_e:
39 strncpy(m_message,
"internal error, invalid json instance type", max_message_length);
42 strncpy(m_message,
"instance is not a number", max_message_length);
44 case cant_compare_raw_e:
45 strncpy(m_message,
"raw values can't be compared", max_message_length);
48 strncpy(m_message,
"raw values can't be cast", max_message_length);
50 case pointer_not_matched_e:
51 strncpy(m_message,
"pointer doesn't match a location in the instance", max_message_length);
53 case pointer_token_type_invalid_e:
54 strncpy(m_message,
"pointer token type is invalid", max_message_length);
57 strncpy(m_message,
"generic", max_message_length);
62 json_exception::json_exception(
exception_type et,
const char *json_type_name) noexcept : exception(), m_type(et)
67 snprintf(m_message, max_message_length,
"instance type is %s not array", json_type_name);
70 snprintf(m_message, max_message_length,
"instance type is %s not object", json_type_name);
72 case not_number_int_or_boolean_e:
73 snprintf(m_message, max_message_length,
"instance type is %s not integer number or boolean", json_type_name);
76 snprintf(m_message, max_message_length,
"instance type is %s not string", json_type_name);
78 case not_number_or_string_e:
79 snprintf(m_message, max_message_length,
"attempt to set a raw value of an instance of type %s (only works for number and string)", json_type_name);
82 strncpy(m_message,
"generic", max_message_length);
87 json_exception::json_exception(
89 const char *first_json_type_name,
90 const char *second_json_type_name) noexcept : exception(), m_type(et)
92 if (et == types_not_comparable_e)
94 snprintf(m_message, max_message_length,
"attempt to compare %s with %s", first_json_type_name, second_json_type_name);
98 strncpy(m_message,
"generic", max_message_length);
102 const char *json_exception::what() const noexcept
112 ostream &NAMESPACE::operator<<(ostream& stream,
const NAMESPACE::json_exception &e)
114 return stream << e.what();
The json_exception class.
#define NAMESPACE
You can change the namespace of the whole library by changing this value.
Common defs needed everywhere and, as far as is possible, platform specific changes.