Diag-Client-Lib
Public Member Functions | Private Attributes | List of all members
core_type::ErrorCode Class Referencefinal

Encapsulation of an error code. An ErrorCode contains a raw error code value and an error domain. The raw error code value is specific to this error domain. More...

#include <error_code.h>

Collaboration diagram for core_type::ErrorCode:
Collaboration graph
[legend]

Public Member Functions

template<typename EnumT >
 ErrorCode (EnumT e, ErrorDomain::SupportDataType data=ErrorDomain::SupportDataType{}) noexcept
 Construct a new ErrorCode instance with parameters. More...
 
 ErrorCode (ErrorDomain::CodeType value, ErrorDomain &domain, ErrorDomain::SupportDataType data=ErrorDomain::SupportDataType{}) noexcept
 Construct a new ErrorCode instance with parameters. More...
 
constexpr ErrorDomain::CodeType Value () const noexcept
 Return the raw error code value. More...
 
constexpr const ErrorDomainDomain () const noexcept
 Return the domain with which this ErrorCode is associated. More...
 
constexpr ErrorDomain::SupportDataType SupportData () const noexcept
 Return the supplementary error context data. More...
 
std::string_view Message () noexcept
 Return a textual representation of this ErrorCode. More...
 

Private Attributes

ErrorDomain::CodeType code_value_ {}
 Store the domain error code value. More...
 
ErrorDomaindomain_
 Store the reference to error domain contained. More...
 
ErrorDomain::SupportDataType support_data_ {}
 Store the supported data. More...
 

Detailed Description

Encapsulation of an error code. An ErrorCode contains a raw error code value and an error domain. The raw error code value is specific to this error domain.

This class is implemented based on API specification of ara::core::ErrorCode from Adaptive Platform Core AUTOSAR AP R21-11

Definition at line 22 of file error_code.h.

Constructor & Destructor Documentation

◆ ErrorCode() [1/2]

template<typename EnumT >
core_type::ErrorCode::ErrorCode ( EnumT  e,
ErrorDomain::SupportDataType  data = ErrorDomain::SupportDataType{} 
)
explicitnoexcept

Construct a new ErrorCode instance with parameters.

This constructor does not participate in overload resolution unless EnumT is an enum type

Template Parameters
EnumTAn enum type that contains error code values
Parameters
[in]eA domain-specific error code value
[in]dataOptional vendor-specific supplementary error context data

Definition at line 14 of file error_code.cpp.

14  : code_value_{e},
15  support_data_{data} {}
ErrorDomain::CodeType code_value_
Store the domain error code value.
Definition: error_code.h:80
ErrorDomain::SupportDataType support_data_
Store the supported data.
Definition: error_code.h:90

◆ ErrorCode() [2/2]

core_type::ErrorCode::ErrorCode ( ErrorDomain::CodeType  value,
ErrorDomain domain,
ErrorDomain::SupportDataType  data = ErrorDomain::SupportDataType{} 
)
noexcept

Construct a new ErrorCode instance with parameters.

Template Parameters
EnumTAn enum type that contains error code values
Parameters
[in]valueA domain-specific error code value
[in]domainThe ErrorDomain associated with value
[in]dataOptional vendor-specific supplementary error context data

Definition at line 17 of file error_code.cpp.

18  : code_value_{value},
19  domain_{domain},
20  support_data_{data} {}
ErrorDomain & domain_
Store the reference to error domain contained.
Definition: error_code.h:85

Member Function Documentation

◆ Domain()

constexpr const ErrorDomain & core_type::ErrorCode::Domain ( ) const
constexprnoexcept

Return the domain with which this ErrorCode is associated.

Returns
The reference to error domain

Definition at line 24 of file error_code.cpp.

24 { return domain_; }

References domain_.

◆ Message()

std::string_view core_type::ErrorCode::Message ( )
noexcept

Return a textual representation of this ErrorCode.

Returns
The error message

Definition at line 28 of file error_code.cpp.

28 { return std::string_view{domain_.Message(code_value_)}; }
virtual const char * Message(CodeType error_code) noexcept=0
Return a textual representation of the given error code.

References code_value_, domain_, and core_type::ErrorDomain::Message().

Here is the call graph for this function:

◆ SupportData()

constexpr ErrorDomain::SupportDataType core_type::ErrorCode::SupportData ( ) const
constexprnoexcept

Return the supplementary error context data.

The underlying type and the meaning of the returned value are implementation-defined

Returns
The support data type

Definition at line 26 of file error_code.cpp.

26 { return support_data_; }

References support_data_.

◆ Value()

constexpr ErrorDomain::CodeType core_type::ErrorCode::Value ( ) const
constexprnoexcept

Return the raw error code value.

Returns
The raw code value

Definition at line 22 of file error_code.cpp.

22 { return code_value_; }

References code_value_.

Member Data Documentation

◆ code_value_

ErrorDomain::CodeType core_type::ErrorCode::code_value_ {}
private

Store the domain error code value.

Definition at line 80 of file error_code.h.

Referenced by Message(), and Value().

◆ domain_

ErrorDomain& core_type::ErrorCode::domain_
private

Store the reference to error domain contained.

Definition at line 85 of file error_code.h.

Referenced by Domain(), and Message().

◆ support_data_

ErrorDomain::SupportDataType core_type::ErrorCode::support_data_ {}
private

Store the supported data.

Definition at line 90 of file error_code.h.

Referenced by SupportData().


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