userver: protobuf::json::ConversionErrorInfo< TErrorCode, typename > Class Template Reference
Loading...
Searching...
No Matches
protobuf::json::ConversionErrorInfo< TErrorCode, typename > Class Template Reference

#include </data/code/userver/libraries/protobuf/include/userver/protobuf/json/exceptions.hpp>

Detailed Description

template<typename TErrorCode, typename = std::enable_if_t< std::is_same_v<TErrorCode, ParseErrorCode> || std::is_same_v<TErrorCode, PrintErrorCode>>>
class protobuf::json::ConversionErrorInfo< TErrorCode, typename >

JSON/protobuf conversion error information.

Template Parameters
TErrorCodeerror code type

Definition at line 49 of file exceptions.hpp.

Public Types

using ErrorCodeType = TErrorCode
 

Public Member Functions

 ConversionErrorInfo (const ErrorCodeType code, std::string path) noexcept
 Creates error information for invalid JSON/protobuf field identified by path . See ConversionErrorInfo::GetPath for more information about path format.
 
ErrorCodeType GetCode () const noexcept
 Returns error code.
 
const std::string & GetPath () const &noexcept
 Returns invalid field path. Parameter path format depends on the conversion direction:
 
std::string GetPath () &&noexcept
 Returns invalid field path. See ConversionErrorInfo::GetPath for more information about path format.
 

Member Typedef Documentation

◆ ErrorCodeType

template<typename TErrorCode, typename = std::enable_if_t< std::is_same_v<TErrorCode, ParseErrorCode> || std::is_same_v<TErrorCode, PrintErrorCode>>>
using protobuf::json::ConversionErrorInfo< TErrorCode, typename >::ErrorCodeType = TErrorCode

Definition at line 51 of file exceptions.hpp.

Constructor & Destructor Documentation

◆ ConversionErrorInfo()

template<typename TErrorCode, typename = std::enable_if_t< std::is_same_v<TErrorCode, ParseErrorCode> || std::is_same_v<TErrorCode, PrintErrorCode>>>
protobuf::json::ConversionErrorInfo< TErrorCode, typename >::ConversionErrorInfo ( const ErrorCodeType code,
std::string path )
inlinenoexcept

Creates error information for invalid JSON/protobuf field identified by path . See ConversionErrorInfo::GetPath for more information about path format.

Definition at line 55 of file exceptions.hpp.

Member Function Documentation

◆ GetCode()

template<typename TErrorCode, typename = std::enable_if_t< std::is_same_v<TErrorCode, ParseErrorCode> || std::is_same_v<TErrorCode, PrintErrorCode>>>
ErrorCodeType protobuf::json::ConversionErrorInfo< TErrorCode, typename >::GetCode ( ) const
inlinenodiscardnoexcept

Returns error code.

Definition at line 58 of file exceptions.hpp.

◆ GetPath() [1/2]

template<typename TErrorCode, typename = std::enable_if_t< std::is_same_v<TErrorCode, ParseErrorCode> || std::is_same_v<TErrorCode, PrintErrorCode>>>
std::string protobuf::json::ConversionErrorInfo< TErrorCode, typename >::GetPath ( ) &&
inlinenodiscardnoexcept

Returns invalid field path. See ConversionErrorInfo::GetPath for more information about path format.

Definition at line 74 of file exceptions.hpp.

◆ GetPath() [2/2]

template<typename TErrorCode, typename = std::enable_if_t< std::is_same_v<TErrorCode, ParseErrorCode> || std::is_same_v<TErrorCode, PrintErrorCode>>>
const std::string & protobuf::json::ConversionErrorInfo< TErrorCode, typename >::GetPath ( ) const &
inlinenodiscardnoexcept

Returns invalid field path. Parameter path format depends on the conversion direction:

  1. In case of JSON to protobuf conversion, path will be formatted in a way used for exceptions thrown by by various ValueBuilder and Value class methods (seeformats::json::ExceptionWithPath): / (root), field.array[0].item, etc. Field names will be taken from JSON and may not match target field names in the protobuf message (ProtoJSON by default uses lowerCamelCase-encoded protobuf field names as JSON field names).
  2. In case of protobuf message to JSON conversion, path will be formatted in a similar way as above, however map types will be handled explicitly. Examples: / (root), ‘field.repeated[0].item.map['key’].value`, etc. Field names will be taken from the protobuf message and may not match target field names in the JSON.

Definition at line 70 of file exceptions.hpp.


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