Woman, Life, Freedom
Adaptive AUTOSAR
ARA public interface header documentation
error_code.h
1
#ifndef ERROR_CODE_H
2
#define ERROR_CODE_H
3
4
#include <string>
5
#include "./error_domain.h"
6
7
namespace
ara
8
{
9
namespace
core
10
{
12
class
ErrorCode
final
13
{
14
private
:
15
ErrorDomain::CodeType
mValue;
16
const
ErrorDomain
& mDomain;
17
18
public
:
22
constexpr
ErrorCode
(
23
ErrorDomain::CodeType
value,
24
const
ErrorDomain
&domain) noexcept : mValue{value}, mDomain{domain}
25
{
26
}
27
28
ErrorCode() =
delete
;
29
~ErrorCode() noexcept = default;
30
33
constexpr
ErrorDomain
::CodeType
Value
() const noexcept
34
{
35
return
mValue;
36
}
37
40
constexpr
ErrorDomain
const
&
Domain
() const noexcept
41
{
42
return
mDomain;
43
}
44
47
std::string
Message
() const noexcept;
48
50
void
ThrowAsException
() const;
51
52
constexpr
bool
operator==(const
ErrorCode
&other) const noexcept
53
{
54
return
mDomain == other.mDomain && mValue == other.mValue;
55
}
56
57
constexpr
bool
operator!=(
const
ErrorCode &other)
const
noexcept
58
{
59
return
mDomain != other.mDomain || mValue != other.mValue;
60
}
61
};
62
}
63
}
64
65
#endif
ara::core::ErrorCode
A wrapper around the raw error code in a specific ErrorDomain.
Definition:
error_code.h:13
ara::core::ErrorCode::Message
std::string Message() const noexcept
Get error message.
Definition:
error_code.cpp:8
ara::core::ErrorCode::ErrorCode
constexpr ErrorCode(ErrorDomain::CodeType value, const ErrorDomain &domain) noexcept
Constructor.
Definition:
error_code.h:22
ara::core::ErrorCode::Value
constexpr ErrorDomain::CodeType Value() const noexcept
Get error code value.
Definition:
error_code.h:33
ara::core::ErrorCode::Domain
constexpr ErrorDomain const & Domain() const noexcept
Get error code domain.
Definition:
error_code.h:40
ara::core::ErrorCode::ThrowAsException
void ThrowAsException() const
Throw the error as an exception.
Definition:
error_code.cpp:14
ara::core::ErrorDomain
A class that defines the domain of an ErrorCode to avoid code interferences.
Definition:
error_domain.h:14
ara::core::ErrorDomain::CodeType
uint32_t CodeType
Alias type of the error code.
Definition:
error_domain.h:19
src
ara
core
error_code.h
Generated by
1.9.2