Diag-Client-Lib
error_domain.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_DOMAIN_H_
9 #define DIAG_CLIENT_LIB_LIB_PLATFORM_CORE_ERROR_DOMAIN_H_
10 
11 #include <cstdint>
12 
13 namespace core_type {
14 
20 class ErrorDomain {
21  public:
25  using IdType = std::uint64_t;
26 
30  using CodeType = std::int32_t;
31 
35  using SupportDataType = std::uint8_t;
36 
40  ErrorDomain(const ErrorDomain &) = delete;
41 
45  ErrorDomain(ErrorDomain &&) = delete;
46 
50  ErrorDomain &operator=(const ErrorDomain &) = delete;
51 
56 
61  constexpr IdType Id() const noexcept;
62 
67  virtual const char *Name() const noexcept = 0;
68 
75  virtual const char *Message(CodeType error_code) noexcept = 0;
76 
77  protected:
83  explicit ErrorDomain(IdType id) noexcept;
84 
90  virtual ~ErrorDomain() noexcept = default;
91 
92  private:
97 };
98 
99 } // namespace core_type
100 
101 #endif // DIAG_CLIENT_LIB_LIB_PLATFORM_CORE_ERROR_DOMAIN_H_
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
ErrorDomain(ErrorDomain &&)=delete
Move construction shall be disabled.
ErrorDomain & operator=(ErrorDomain &&)=delete
Move assignment shall be disabled.
ErrorDomain & operator=(const ErrorDomain &)=delete
Copy assignment shall be disabled.
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
virtual const char * Name() const noexcept=0
Return the name of this error domain.
constexpr IdType Id() const noexcept
Return the unique domain identifier.
ErrorDomain(const ErrorDomain &)=delete
Copy construction shall be disabled.
std::uint64_t IdType
Type alias for a unique ErrorDomain identifier type.
Definition: error_domain.h:25
IdType id_
Store the unique identifier.
Definition: error_domain.h:96