Encapsulation of an error code. An ErrorCode contains a raw error code value and an Error Domain. The raw error code value is specific to this ErrorDomain.
Encapsulates domain-specific error codes and supplementary data for evaluation or conversion into C++ exceptions.
AI-GENERATEDunreviewedModel: gemini-3.8-flash-medium · Effort: medium · Temperature: not controllable · Prompt: 747258139aa5ProvenanceOpen questions (1)
translated from the German guidegemini-3.8-flash-low · 2026-10-13 · German original
Encapsulates domain-specific error codes and supplementary data for evaluation or conversion into C++ exceptions.
Class ara::core::ErrorCode encapsulates a domain-specific raw error value along with its associated error domain and optional context data [SWS_CORE_00513]. It enables exception-safe retrieval of error codes and descriptive texts, as well as on-demand propagation as a type-specific C++ exception via ThrowAsException()[SWS_CORE_00518], [SWS_CORE_00519]. If C++ exceptions are disabled on the toolchain side, the exception interface is automatically omitted from overload resolution [SWS_CORE_00519].
Context
Class ara::core::ErrorCode serves as a central encapsulation for error information in the AUTOSAR Adaptive Platform. An error code always bundles a domain-specific raw error value of type ErrorDomain::CodeType with an associated error domain ara::core::ErrorDomain[SWS_CORE_00513]. The error domain defines the semantic context in which the raw value is to be interpreted and establishes the connection between numeric code and technical meaning [SWS_CORE_00515]. In addition, an ErrorCode can hold vendor-specific supplementary data of type ErrorDomain::SupportDataType to provide extended context regarding error emergence without dynamic memory allocation [SWS_CORE_00516].
Lifecycle
Instantiation of an ErrorCode is performed either via an enumerable type or via explicit specification of raw value and error domain. For type-safe enumeration values, a constructor template exists that participates in overload resolution via SFINAE exclusively if the argument is a C++ enum type [SWS_CORE_00512]. Alternatively, the direct constructor accepts a numeric raw value, a reference to the responsible ErrorDomain, and optional supplementary data [SWS_CORE_00513].
Both constructors are declared as constexpr and noexcept. This guarantees complete exception safety during construction and permits construction as early as compile time [SWS_CORE_00512], [SWS_CORE_00513]. Interpretation: Since ErrorCode manages only primitive data and a reference to the long-lived domain, the class behaves as a lightweight value type that can be freely copied and read across threads. Question Q-8ac788b51fb75a1c (open) All observing operations are specified as thread-safe and exception-safe [SWS_CORE_00514], [SWS_CORE_00515].
Usage Path
A typical usage flow comprises creation upon detection of an error condition, inspection of relevant metadata by the caller, and, if needed, forwarding into exception handling:
Creation: The error is constructed via a domain-specific enumeration value and optional context data [SWS_CORE_00512].
Identification: The caller queries the numeric raw value using Value()[SWS_CORE_00514] and the associated error domain via Domain()[SWS_CORE_00515].
Diagnosis: Supplementary vendor-specific data is read via SupportData()[SWS_CORE_00516], while Message() yields a human-readable description as StringView[SWS_CORE_00518].
Throwing exceptions: If the error is to be propagated within an exception-based control structure, the caller throws the associated exception via ThrowAsException()[SWS_CORE_00519].
Class ara::core::ErrorCode acts as a bridge between exception-free and exception-based error management. Methods Value(), Domain(), SupportData(), and Message() have the guarantee noexcept and can be called without risk of consequential errors even under resource constraints [SWS_CORE_00514], [SWS_CORE_00515], [SWS_CORE_00516], [SWS_CORE_00518].
A distinct error scenario is presented by method ThrowAsException(), which is explicitly declared as noexcept(false) and not exception safe[SWS_CORE_00519]. Its behavior corresponds to the call this->Domain().ThrowAsException(*this); via the associated ErrorDomain, it determines the appropriate exception type and throws an exception that encapsulates the current ErrorCode instance [SWS_CORE_00519]. An essential constraint is that ThrowAsException() does not participate in overload resolution if C++ exceptions are disabled in the compiler toolchain [SWS_CORE_00519].
Generated by autodocs AI based on AUTOSAR Adaptive Platform R25-11.
Construct a new ErrorCode instance with parameters
AI-GENERATEDunreviewedModel: gemini-3.8-flash-medium · Effort: medium · Temperature: not controllable · Prompt: aa921d126307ProvenanceOpen questions (1)
translated from the German guidegemini-3.8-flash-low · 2026-10-13 · German original
The template constructor ErrorCode synchronously instantiates an error description within class ara::core::ErrorCode from header file ara/core/error_code.h[SWS_CORE_00512]. It takes a domain-specific error code value e of an enumeration type EnumT as well as optional vendor-specific additional data data of type ErrorDomain::SupportDataType, which are initialized to empty by default [SWS_CORE_00512]. As a major constraint, the constructor participates in overload resolution via SFINAE only if EnumT is indeed an enumeration type [SWS_CORE_00512]. In contrast to the alternative overload with explicit domain passing [SWS_CORE_00513], the association with the matching ErrorDomain is presumably deduced implicitly based on the type EnumT. Question Q-83bc8268971748ff (open)
Regarding concurrency and exception safety, the constructor is specified as thread-safe (thread-safe) as well as completely exception safe (exception safe) and declared as noexcept[SWS_CORE_00512]. Due to the constexpr qualification, instantiation can already take place at compile time in constant expressions [SWS_CORE_00512]. Specific DET or DEM error reports are not defined for construction. If the represented error is to be signaled as an exception in the further control flow, the created instance provides the method ThrowAsException(), which determines and throws the appropriate exception type [SWS_CORE_00519]; correspondingly, the error domain can also throw the exception directly [SWS_CORE_00154].
In interaction with the overall system, the properties of the object can be queried via methods Value()[SWS_CORE_00514], Domain()[SWS_CORE_00515], SupportData()[SWS_CORE_00516], and the textual representation Message()[SWS_CORE_00518]. In value comparisons via operator==[SWS_CORE_00571] and operator!=[SWS_CORE_00572], only Value() and Domain() are taken into account, whereas SupportData() remains disregarded [SWS_CORE_00571]. Furthermore, the created object serves as the basis for encapsulation in standardized exception objects such as ara::core::Exception[SWS_CORE_00611] (readable via Error()[SWS_CORE_00613]), ara::core::CoreException[SWS_CORE_05212], or ara::core::FutureException[SWS_CORE_00412].
Note: This usage note was generated by an artificial intelligence and is based exclusively on the specifications of release R25-11.
AI-GENERATEDunreviewedModel: gemini-3.8-flash-medium · Effort: medium · Temperature: not controllable · Prompt: f7a24bdeeeddProvenance
translated from the German guidegemini-3.8-flash-low · 2026-10-13 · German original
The member function SupportData() of class ara::core::ErrorCode from header #include "ara/core/error_code.h" returns supplementary context data for an error [SWS_CORE_00516]. The method is called synchronously on an instance, requires no parameters, and returns a value of type ErrorDomain::SupportDataType[SWS_CORE_00516]. Being declared as constexpr and noexcept, the call is guaranteed to be exception-free and can already be evaluated at compile time [SWS_CORE_00516].
Regarding concurrency and execution safety, the method is specified as thread-safe (thread-safe) and exception safe (exception safe) [SWS_CORE_00516]. Since this is a read-only access to the internal error context, no error conditions occur, making the call suitable also for critical and concurrent execution paths [SWS_CORE_00516].
In interaction with the other error handling interfaces, SupportData() reads those vendor-specific supplementary data that were optionally passed to the constructor of ErrorCode via parameter data[SWS_CORE_00513]. When comparing two error codes using operator==, it should be noted that instances are evaluated as equal exclusively based on the returns of Value() and Domain(); the return value of SupportData() is explicitly not used for equality comparison [SWS_CORE_00571].
This usage note was generated automatically based on the specification AUTOSAR Adaptive R25-11.
This function will determine the appropriate exception type for this ErrorCode and throw it. The thrown exception will contain this ErrorCode.
AI-GENERATEDunreviewedModel: gemini-3.8-flash-medium · Effort: medium · Temperature: not controllable · Prompt: 3205bd108ecbProvenance
translated from the German guidegemini-3.8-flash-low · 2026-10-13 · German original
The member function ThrowAsException of class ara::core::ErrorCode is used to throw an occurred error synchronously as a C++ exception ([SWS_CORE_00519]). The function takes no parameters and has no return value, since regular control flow is interrupted by throwing the exception.
To determine the concrete exception type, the method delegates throwing to the assigned error domain according to the behavior this->Domain().ThrowAsException(*this) ([SWS_CORE_00519]). Via the interface of the base class ara::core::ErrorDomain ([SWS_CORE_00154]), the respective domain determines the matching exception type according to the specification of [SWS_CORE_10953]. The thrown exception always contains the throwing ErrorCode instance. Concrete domains implement this specifically:
ara::core::FutureErrorDomain throws a FutureException with the passed error instance ([SWS_CORE_00444]).
Regarding concurrency and constraints, ThrowAsException is specified as thread-safe ([SWS_CORE_00519]). Exception safety is declared as not exception safe, and the signature explicitly features noexcept(false) ([SWS_CORE_00519]). A central restriction of the toolchain is that the function does not participate in overload resolution if C++ exceptions are disabled in the compiler ([SWS_CORE_00519]).
This usage note is based on the AUTOSAR specifications of release R25-11.
Any exception of the type determined by the associated ErrorDomain as defined in [SWS_CORE_10953]
Hinweise: This function shall not participate in overload resolution when C++ exceptions are disabled in the compiler toolchain. Behaves as if this->Domain().ThrowAsException(*this).
Request a governed re-review of this record. The record is not changed immediately.
gemini-3.8-flash-low· 2026-10-13 · German original