WPILibC++  2019.3.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages
wpi::detail::type_error Class Reference

exception indicating executing a member function with a wrong type More...

#include <json.h>

Inheritance diagram for wpi::detail::type_error:
wpi::detail::exception

Static Public Member Functions

static type_error create (int id_, const Twine &what_arg)
 

Additional Inherited Members

- Public Member Functions inherited from wpi::detail::exception
const char * what () const noexceptoverride
 returns the explanatory string
 
- Public Attributes inherited from wpi::detail::exception
const int id
 the id of the exception
 
- Protected Member Functions inherited from wpi::detail::exception
 exception (int id_, const Twine &what_arg)
 

Detailed Description

exception indicating executing a member function with a wrong type

This exception is thrown in case of a type error; that is, a library function is executed on a JSON value whose type does not match the expected semantics.

Exceptions have ids 3xx.

name / id example message description
json.exception.type_error.301 cannot create object from initializer list To create an object from an initializer list, the initializer list must consist only of a list of pairs whose first element is a string. When this constraint is violated, an array is created instead.
json.exception.type_error.302 type must be object, but is array During implicit or explicit value conversion, the JSON type must be compatible to the target type. For instance, a JSON string can only be converted into string types, but not into numbers or boolean types.
json.exception.type_error.303 incompatible ReferenceType for get_ref, actual type is object To retrieve a reference to a value stored in a json object with get_ref, the type of the reference must match the value type. For instance, for a JSON array, the ReferenceType must be array_t&.
json.exception.type_error.304 cannot use at() with string The at() member functions can only be executed for certain JSON types.
json.exception.type_error.305 cannot use operator[] with string The operator[] member functions can only be executed for certain JSON types.
json.exception.type_error.306 cannot use value() with string The value() member functions can only be executed for certain JSON types.
json.exception.type_error.307 cannot use erase() with string The erase() member functions can only be executed for certain JSON types.
json.exception.type_error.308 cannot use push_back() with string The push_back() and operator+= member functions can only be executed for certain JSON types.
json.exception.type_error.309 cannot use insert() with The insert() member functions can only be executed for certain JSON types.
json.exception.type_error.310 cannot use swap() with number The swap() member functions can only be executed for certain JSON types.
json.exception.type_error.311 cannot use emplace_back() with string The emplace_back() member function can only be executed for certain JSON types.
json.exception.type_error.312 cannot use update() with string The update() member functions can only be executed for certain JSON types.
json.exception.type_error.313 invalid value to unflatten The unflatten function converts an object whose keys are JSON Pointers back into an arbitrary nested JSON value. The JSON Pointers must not overlap, because then the resulting value would not be well defined.
json.exception.type_error.314 only objects can be unflattened The unflatten function only works for an object whose keys are JSON Pointers.
json.exception.type_error.315 values in object must be primitive The unflatten function only works for an object whose keys are JSON Pointers and whose values are primitive.
json.exception.type_error.316 invalid UTF-8 byte at index 10: 0x7E The dump function only works with UTF-8 encoded strings; that is, if you assign a std::string to a JSON value, make sure it is UTF-8 encoded.

{The following code shows how a type_error exception can be caught.,type_error}

See also
exception for the base class of the library exceptions
parse_error for exceptions indicating a parse error
invalid_iterator for exceptions indicating errors with iterators
out_of_range for exceptions indicating access out of the defined range
other_error for exceptions indicating other library errors
Since
version 3.0.0

The documentation for this class was generated from the following file: