Error
The <system_error>
framework is used for error codes and exceptions.
Error codes and utilities are located in the <trial/protocol/json/error.hpp> header.
|
Error codes
Trial.Protocol defines its own json::error_category with associated error
enumerator constants.
Normally, an error_code of the current error can be obtained via an error()
member function.
std::string input = "illegal";
json::reader reader(input);
assert(reader.symbol() == json::symbol::error);
assert(reader.error() == json::invalid_value);
This conversion can also be done manually with json::to_errc() and
json::make_error_code().
std::string input = "illegal";
json::reader reader(input);
assert(reader.symbol() == json::symbol::error);
assert(reader.code() == json::code::error_invalid_value);
enum json::errc ec = json::to_errc(reader.code());
assert(ec == json::invalid_value);
auto error = json::make_error_code(ec);
assert(error == json::invalid_value);
The following error codes exists.
|
Description |
|
An unexpected token is encountered in the input. |
|
An associative array key is not in a valid format. |
|
The content is not in a valid format. |
|
Conversion between two incompatible types failed. |
|
Encountered an end array token without a corresponding begin array token. |
|
Encountered an end object token without a corresponding begin object token. |
|
Encountered an end array token outside an array. |
|
Encountered an end object token outside an associative array. |