RapidJSON error handling#
Classes | |
| struct | ParseResult |
| Result of parsing (wraps ParseErrorCode). More... | |
Macros | |
| #define | RAPIDJSON_ERROR_CHARTYPE char |
| Character type of error messages. | |
| #define | RAPIDJSON_ERROR_STRING(x) |
| Macro for converting string literal to RAPIDJSON_ERROR_CHARTYPE[]. | |
| #define | RAPIDJSON_PARSE_ERROR_NORETURN(parseErrorCode, offset) |
| Macro to indicate a parse error. | |
| #define | RAPIDJSON_PARSE_ERROR(parseErrorCode, offset) |
| (Internal) macro to indicate and handle a parse error. | |
Typedefs | |
| typedef const RAPIDJSON_ERROR_CHARTYPE *(* | GetParseErrorFunc) (ParseErrorCode) |
| Function pointer type of GetParseError(). | |
| typedef const RAPIDJSON_ERROR_CHARTYPE *(* | GetValidateErrorFunc) (ValidateErrorCode) |
| Function pointer type of GetValidateError(). | |
| typedef const RAPIDJSON_ERROR_CHARTYPE *(* | GetSchemaErrorFunc) (SchemaErrorCode) |
| Function pointer type of GetSchemaError(). | |
| typedef const RAPIDJSON_ERROR_CHARTYPE *(* | GetPointerParseErrorFunc) (PointerParseErrorCode) |
| Function pointer type of GetPointerParseError(). | |
Functions | |
| RAPIDJSON_NAMESPACE_BEGIN const RAPIDJSON_ERROR_CHARTYPE * | GetParseError_En (ParseErrorCode parseErrorCode) |
| Maps error code of parsing into error message. | |
| const RAPIDJSON_ERROR_CHARTYPE * | GetValidateError_En (ValidateErrorCode validateErrorCode) |
| Maps error code of validation into error message. | |
| const RAPIDJSON_ERROR_CHARTYPE * | GetSchemaError_En (SchemaErrorCode schemaErrorCode) |
| Maps error code of schema document compilation into error message. | |
| const RAPIDJSON_ERROR_CHARTYPE * | GetPointerParseError_En (PointerParseErrorCode pointerParseErrorCode) |
| Maps error code of pointer parse into error message. | |
Detailed Description
Macro Definition Documentation
◆ RAPIDJSON_ERROR_CHARTYPE
| #define RAPIDJSON_ERROR_CHARTYPE char |
Character type of error messages.
The default character type is char. On Windows, user can define this macro as TCHAR for supporting both unicode/non-unicode settings.
◆ RAPIDJSON_ERROR_STRING
| #define RAPIDJSON_ERROR_STRING | ( | x | ) |
Macro for converting string literal to RAPIDJSON_ERROR_CHARTYPE[].
By default this conversion macro does nothing. On Windows, user can define this macro as _T(x) for supporting both unicode/non-unicode settings.
◆ RAPIDJSON_PARSE_ERROR
| #define RAPIDJSON_PARSE_ERROR | ( | parseErrorCode, | |
| offset ) |
(Internal) macro to indicate and handle a parse error.
- Parameters
-
parseErrorCode rapidjson::ParseErrorCode of the error offset position of the error in JSON input ( size_t)
Invokes RAPIDJSON_PARSE_ERROR_NORETURN and stops the parsing.
- See also
- RAPIDJSON_PARSE_ERROR_NORETURN
◆ RAPIDJSON_PARSE_ERROR_NORETURN
| #define RAPIDJSON_PARSE_ERROR_NORETURN | ( | parseErrorCode, | |
| offset ) |
Macro to indicate a parse error.
- Parameters
-
parseErrorCode rapidjson::ParseErrorCode of the error offset position of the error in JSON input ( size_t)
This macros can be used as a customization point for the internal error handling mechanism of RapidJSON.
A common usage model is to throw an exception instead of requiring the caller to explicitly check the rapidjson::GenericReader::Parse's return value:
- See also
- RAPIDJSON_PARSE_ERROR, rapidjson::GenericReader::Parse
Typedef Documentation
◆ GetParseErrorFunc
| typedef const RAPIDJSON_ERROR_CHARTYPE *(* GetParseErrorFunc) (ParseErrorCode) |
Function pointer type of GetParseError().
This is the prototype for GetParseError_X(), where X is a locale. User can dynamically change locale in runtime, e.g.:
◆ GetPointerParseErrorFunc
| typedef const RAPIDJSON_ERROR_CHARTYPE *(* GetPointerParseErrorFunc) (PointerParseErrorCode) |
Function pointer type of GetPointerParseError().
This is the prototype for GetPointerParseError_X(), where X is a locale. User can dynamically change locale in runtime, e.g.:
◆ GetSchemaErrorFunc
| typedef const RAPIDJSON_ERROR_CHARTYPE *(* GetSchemaErrorFunc) (SchemaErrorCode) |
Function pointer type of GetSchemaError().
This is the prototype for GetSchemaError_X(), where X is a locale. User can dynamically change locale in runtime, e.g.:
◆ GetValidateErrorFunc
| typedef const RAPIDJSON_ERROR_CHARTYPE *(* GetValidateErrorFunc) (ValidateErrorCode) |
Function pointer type of GetValidateError().
This is the prototype for GetValidateError_X(), where X is a locale. User can dynamically change locale in runtime, e.g.:
Enumeration Type Documentation
◆ ParseErrorCode
| enum ParseErrorCode |
Error code of parsing.
◆ PointerParseErrorCode
Error code of JSON pointer parsing.
- See also
- GenericPointer::GenericPointer, GenericPointer::GetParseErrorCode
◆ SchemaErrorCode
| enum SchemaErrorCode |
Error codes when validating.
- See also
- GenericSchemaValidator
| Enumerator | |
|---|---|
| kSchemaErrorNone | No error. |
| kSchemaErrorStartUnknown | Pointer to start of schema does not resolve to a location in the document |
| kSchemaErrorRefPlainName | $ref fragment must be a JSON pointer |
| kSchemaErrorRefInvalid | $ref must not be an empty string |
| kSchemaErrorRefPointerInvalid | $ref fragment is not a valid JSON pointer at offset |
| kSchemaErrorRefUnknown | $ref does not resolve to a location in the target document |
| kSchemaErrorRefCyclical | $ref is cyclical |
| kSchemaErrorRefNoRemoteProvider | $ref is remote but there is no remote provider |
| kSchemaErrorRefNoRemoteSchema | $ref is remote but the remote provider did not return a schema |
| kSchemaErrorRegexInvalid | Invalid regular expression in 'pattern' or 'patternProperties'. |
| kSchemaErrorSpecUnknown | JSON schema draft or OpenAPI version is not recognized. |
| kSchemaErrorSpecUnsupported | JSON schema draft or OpenAPI version is not supported. |
| kSchemaErrorSpecIllegal | Both JSON schema draft and OpenAPI version found in document. |
| kSchemaErrorReadOnlyAndWriteOnly | Property must not be both 'readOnly' and 'writeOnly'. |
◆ ValidateErrorCode
| enum ValidateErrorCode |
Error codes when validating.
- See also
- GenericSchemaValidator
Function Documentation
◆ GetParseError_En()
|
inline |
Maps error code of parsing into error message.
- Parameters
-
parseErrorCode Error code obtained in parsing.
- Returns
- the error message.
- Note
- User can make a copy of this function for localization. Using switch-case is safer for future modification of error codes.
◆ GetPointerParseError_En()
|
inline |
Maps error code of pointer parse into error message.
- Parameters
-
pointerParseErrorCode Error code obtained from pointer parse.
- Returns
- the error message.
- Note
- User can make a copy of this function for localization. Using switch-case is safer for future modification of error codes.
◆ GetSchemaError_En()
|
inline |
Maps error code of schema document compilation into error message.
- Parameters
-
schemaErrorCode Error code obtained from compiling the schema document.
- Returns
- the error message.
- Note
- User can make a copy of this function for localization. Using switch-case is safer for future modification of error codes.
◆ GetValidateError_En()
|
inline |
Maps error code of validation into error message.
- Parameters
-
validateErrorCode Error code obtained from validator.
- Returns
- the error message.
- Note
- User can make a copy of this function for localization. Using switch-case is safer for future modification of error codes.