Diag-Client-Lib
error_code.cpp
Go to the documentation of this file.
1 /* Diagnostic Client library
2  * Copyright (C) 2024 Avijit Dey
3  *
4  * This Source Code Form is subject to the terms of the Mozilla Public
5  * License, v. 2.0. If a copy of the MPL was not distributed with this
6  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 */
8 
10 
11 namespace core_type {
12 
13 template<typename EnumT>
14 ErrorCode::ErrorCode(EnumT e, ErrorDomain::SupportDataType data) noexcept : code_value_{e},
15  support_data_{data} {}
16 
18  : code_value_{value},
19  domain_{domain},
20  support_data_{data} {}
21 
22 constexpr ErrorDomain::CodeType ErrorCode::Value() const noexcept { return code_value_; }
23 
24 constexpr const ErrorDomain &ErrorCode::Domain() const noexcept { return domain_; }
25 
27 
28 std::string_view ErrorCode::Message() noexcept { return std::string_view{domain_.Message(code_value_)}; }
29 
30 } // namespace core_type
constexpr ErrorDomain::CodeType Value() const noexcept
Return the raw error code value.
Definition: error_code.cpp:22
std::string_view Message() noexcept
Return a textual representation of this ErrorCode.
Definition: error_code.cpp:28
constexpr ErrorDomain::SupportDataType SupportData() const noexcept
Return the supplementary error context data.
Definition: error_code.cpp:26
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
ErrorDomain & domain_
Store the reference to error domain contained.
Definition: error_code.h:85
constexpr const ErrorDomain & Domain() const noexcept
Return the domain with which this ErrorCode is associated.
Definition: error_code.cpp:24
ErrorCode(EnumT e, ErrorDomain::SupportDataType data=ErrorDomain::SupportDataType{}) noexcept
Construct a new ErrorCode instance with parameters.
Definition: error_code.cpp:14
Encapsulation of an error domain. An error domain is the controlling entity for ErrorCode’s error cod...
Definition: error_domain.h:20
std::int32_t CodeType
Type alias for a domain-specific error code value.
Definition: error_domain.h:30
virtual const char * Message(CodeType error_code) noexcept=0
Return a textual representation of the given error code.
std::uint8_t SupportDataType
Type alias type for vendor-specific supplementary data.
Definition: error_domain.h:35