AnCH Framework 0.2
Another C++ Hack: C++23 utility libraries
Loading...
Searching...
No Matches
anch::json::MappingError Class Reference

Mapping error. More...

#include <mappingError.hpp>

Inheritance diagram for anch::json::MappingError:
Collaboration diagram for anch::json::MappingError:

Public Member Functions

 MappingError (ErrorCode code, const anch::json::ReaderContext &context)
 MappingError (ErrorCode code, const anch::json::ReaderContext &context, std::string_view message)
 MappingError (ErrorCode code, std::string_view message)
virtual ~MappingError ()
virtual const char * what () const noexcept override
void prependField (std::string_view field)
void prependIndex (std::size_t index)
anch::json::ErrorCode getErrorCode () const
const std::string & getPath () const

Detailed Description

Mapping error.

Error which can be raised while parsing JSON input stream

Author
Vincent Lachenal
Since
0.1

Constructor & Destructor Documentation

◆ MappingError() [1/3]

anch::json::MappingError::MappingError ( ErrorCode code,
const anch::json::ReaderContext & context )

MappingError constructor

Parameters
codethe error code
contextthe JSON context parser

◆ MappingError() [2/3]

anch::json::MappingError::MappingError ( ErrorCode code,
const anch::json::ReaderContext & context,
std::string_view message )

MappingError constructor with detailed message.
The message replaces the generic message of the error code ; the input around the error is still added.

Parameters
codethe error code
contextthe JSON context parser
messagethe detailed error message

◆ MappingError() [3/3]

anch::json::MappingError::MappingError ( ErrorCode code,
std::string_view message )

MappingError constructor without input (serialization error)

Parameters
codethe error code
messagethe error message
Since
0.2

◆ ~MappingError()

virtual anch::json::MappingError::~MappingError ( )
virtual

MappingError destructor

Member Function Documentation

◆ getErrorCode()

anch::json::ErrorCode anch::json::MappingError::getErrorCode ( ) const

Error code getter

Returns
the error code
Here is the call graph for this function:

◆ getPath()

const std::string & anch::json::MappingError::getPath ( ) const

Path of the value in error getter.
The path is a JSON Pointer (RFC 6901) from the deserialized root value: /pets/3/name for the name field of the fourth item of the pets array. It is empty when the error is not in a field or array item value (root value, field name or separator).
When path is not empty, what() message starts with the path followed by ": " .

Returns
the path
Since
0.2
Here is the call graph for this function:

◆ prependField()

void anch::json::MappingError::prependField ( std::string_view field)

Add object field at the beginning of the path. It is used by mappers when error is propagated from a field value.

Parameters
fieldthe field name (escaped according to JSON Pointer rules: ~ as ~0 and / as ~1 )
Since
0.2
Here is the call graph for this function:

◆ prependIndex()

void anch::json::MappingError::prependIndex ( std::size_t index)

Add array index at the beginning of the path. It is used by mappers when error is propagated from an array item.

Parameters
indexthe item index
Since
0.2
Here is the call graph for this function:

◆ what()

virtual const char * anch::json::MappingError::what ( ) const
overridevirtualnoexcept

Error message getter

Returns
the error message

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