Diag-Client-Lib
dm_error_domain.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 
9 /* includes */
11 
13 
14 namespace diag {
15 namespace client {
16 namespace error_domain {
17 namespace {
18 
22 constexpr core_type::ErrorDomain::IdType unique_identifier{0x5000000000000001};
23 
28 
29 auto ConvertErrorCodeToString(core_type::ErrorDomain::CodeType error_code) noexcept -> std::string {
30  std::string result{};
31  DmErrorErrc const dm_error_code{error_code};
32 
33  switch (dm_error_code) {
35  result = "InitializationFailed";
36  break;
38  result = "DeInitializationFailed";
39  break;
40  }
41  return result;
42 }
43 
44 } // namespace
45 
47 
48 const char* DmErrorDomain::Name() const noexcept { return domain_name_.c_str(); }
49 
50 const char* DmErrorDomain::Message(core_type::ErrorDomain::CodeType error_code) noexcept {
51  message_.clear();
52  message_ = ConvertErrorCodeToString(error_code);
53  return message_.c_str();
54 }
55 
58 }
59 
60 } // namespace error_domain
61 } // namespace client
62 } // namespace diag
Encapsulation of an error code. An ErrorCode contains a raw error code value and an error domain....
Definition: error_code.h:22
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
std::uint64_t IdType
Type alias for a unique ErrorDomain identifier type.
Definition: error_domain.h:25
Definition of Dcm Client Error domain.
DmErrorDomain() noexcept
Default constructor.
const char * Name() const noexcept override
Return the name of this error domain.
const std::string domain_name_
Store the error domain name.
const char * Message(CodeType error_code) noexcept override
Return a textual representation of the given error code.
constexpr core_type::ErrorDomain::IdType unique_identifier
Store the unique identifier of this domain.
auto ConvertErrorCodeToString(core_type::ErrorDomain::CodeType error_code) noexcept -> std::string
DmErrorErrc
Definition of error code in Dcm Client.
core_type::ErrorCode MakeErrorCode(DmErrorErrc, core_type::ErrorDomain::SupportDataType data) noexcept
Create a new ErrorCode within DmErrorDomain.