Diag-Client-Lib
error_code.h
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 #ifndef DIAG_CLIENT_LIB_LIB_PLATFORM_CORE_ERROR_CODE_H_
9 #define DIAG_CLIENT_LIB_LIB_PLATFORM_CORE_ERROR_CODE_H_
10 
11 #include <string_view>
12 
14 
15 namespace core_type {
16 
22 class ErrorCode final {
23  public:
34  template<typename EnumT>
35  explicit ErrorCode(EnumT e, ErrorDomain::SupportDataType data = ErrorDomain::SupportDataType{}) noexcept;
36 
50 
55  constexpr ErrorDomain::CodeType Value() const noexcept;
56 
61  constexpr const ErrorDomain &Domain() const noexcept;
62 
68  constexpr ErrorDomain::SupportDataType SupportData() const noexcept;
69 
74  std::string_view Message() noexcept;
75 
76  private:
81 
86 
91 };
92 
93 } // namespace core_type
94 
95 #endif // DIAG_CLIENT_LIB_LIB_PLATFORM_CORE_ERROR_CODE_H_
Encapsulation of an error code. An ErrorCode contains a raw error code value and an error domain....
Definition: error_code.h:22
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
std::uint8_t SupportDataType
Type alias type for vendor-specific supplementary data.
Definition: error_domain.h:35