ADTF  3.18.2
error_description.h
Go to the documentation of this file.
1 
15 #ifndef A_UTIL_UTIL_RESULT_IMPL_ERROR_DESCRIPTION_HEADER_INCLUDED
16 #define A_UTIL_UTIL_RESULT_IMPL_ERROR_DESCRIPTION_HEADER_INCLUDED
17 
20 
21 #include <string>
22 
23 namespace a_util {
24 namespace result {
25 namespace detail {
29 class ErrorDescription final : public IErrorDescription {
30 public: // const members, disable copy and move semantics
31  ErrorDescription(const ErrorDescription&) = delete;
32  ErrorDescription& operator=(const ErrorDescription&) = delete;
33 
35  ErrorDescription& operator=(ErrorDescription&&) = delete;
36 
38  ~ErrorDescription() = default;
39 
50  inline ErrorDescription(std::int32_t error_code,
51  const char* error_description,
52  std::int32_t line,
53  const char* file,
54  const char* function,
55  const char* error_label);
56 
61  inline std::int32_t getErrorCode() const;
62 
67  inline std::int32_t getLine() const;
68 
73  inline const char* getErrorDescription() const;
74 
79  inline const char* getFileName() const;
80 
85  inline const char* getFunctionName() const;
86 
91  inline const char* getErrorCodeLabel() const;
92 
93 private:
94  const std::int32_t _error_code;
95  const std::int32_t _line_number;
96  const std::string _error_description;
97  const std::string _file_name;
98  const std::string _function_name;
99  const std::string _error_label;
100 }; // class ErrorDescription
101 
104 
113 template <typename T, template <typename = T> class = ::a_util::result::ResultInfo>
115 public:
120  inline std::int32_t getErrorCode() const override;
121 
126  inline const char* getErrorCodeLabel() const override;
127 
128 private:
133  inline std::int32_t getLine() const override;
134 
139  inline const char* getErrorDescription() const override;
140 
145  inline const char* getFileName() const override;
146 
151  inline const char* getFunctionName() const override;
152 };
153 
154 } // namespace detail
155 } // namespace result
156 } // namespace a_util
157 
159 
160 #endif // A_UTIL_UTIL_RESULT_IMPL_ERROR_DESCRIPTION_HEADER_INCLUDED
Implements the error description interface for heap allocated error cases.
const char * getFileName() const
Get name of the file the error was reported in.
const char * getFunctionName() const
Get name of the function the error was reported in.
const std::string _file_name
File in which the error occurred.
std::int32_t getLine() const
Get line in source file where the error was reported.
const char * getErrorDescription() const
Get error code as string representation.
const std::string _error_label
Error code as string representation.
const std::int32_t _line_number
Line number in which the error occurred.
std::int32_t getErrorCode() const
Get error code.
const std::string _error_description
Currently held error description.
const std::string _function_name
Function in which the error occurred.
const char * getErrorCodeLabel() const
Get error code label.
const std::int32_t _error_code
Currently held error code.
Implements the error description interface using static data from a_util::result::ResultInfo<T>
const char * getFunctionName() const override
Does not provide any useful information in this context.
std::int32_t getErrorCode() const override
Get error code using a_util::result::ResultInfo<T>::getCode()
const char * getErrorCodeLabel() const override
Get error label using a_util::result::ResultInfo<T>::getLabel()
const char * getFileName() const override
Does not provide any useful information in this context.
const char * getErrorDescription() const override
Does not provide any useful information in this context.
std::int32_t getLine() const override
Does not provide any useful information in this context.
Define the default error description class for Result return values.
ErrorDescription ErrorDescriptionType
Alias type needed for reference counting.
Serves as the root component, with common functionality documented in core functionality.
Definition: base.h:24
Public API for ResultInfo type, functions and macros.
Basic result information template, used by a_util::result::Result.
Private API for IErrorDescription type.