Serves as the base class for all AUTOSAR exceptions and encapsulates a thread-safe error code for evaluation.
AI-GENERATEDunreviewedModel: gemini-3.8-flash-medium · Effort: medium · Temperature: not controllable · Prompt: d4eaa8466f70ProvenanceOpen questions (1)
translated from the German guidegemini-3.8-flash-low · 2026-10-13 · German original
Serves as the base class for all AUTOSAR exceptions and encapsulates a thread-safe error code for evaluation.
The class ara::core::Exception serves as a common base class for all exception types of the Adaptive Platform and embeds an ErrorCode into the standardized C++ exception hierarchy [SWS_CORE_00611]. When errors occur, it transports this error code in a thread-safe manner to a handler that can evaluate it via Error() or the derived standard method what()[SWS_CORE_00613]. All operations are strictly exception-safe and declared as noexcept. To prevent accidental object slicing with derived types, copy operations are protected.
Context
The class ara::core::Exception serves as a common base class for all exception types within the AUTOSAR Adaptive Platform. It bridges exception handling of the C++ standard library and the AUTOSAR error model: on the one hand, it publicly derives from std::exception and overrides its virtual member function what()[SWS_CORE_00612]; on the other hand, it transports an embedded error object of type ara::core::ErrorCode[SWS_CORE_00611], [SWS_CORE_00613].
The main responsibility of ara::core::Exception is to provide structured error information across call boundaries in exceptional cases. Interpretation: The class is likely designed as a common root for domain-specific exception classes of the platform; its copy operations are specified as protected to prevent accidental object slicing for derived instances [SWS_CORE_00614], [SWS_CORE_00618]. Question Q-20ffec7888b9e724 (open)
Creating an ara::core::Exception strictly requires explicitly specifying an error code when calling constructor [SWS_CORE_00611]. This constructor is defined as noexcept and thus does not throw any exceptions itself.
Ownership and copying options follow strict protection rules: both the copy constructor [SWS_CORE_00618] and the copy assignment operator [SWS_CORE_00614] have the access modifier protected. This prevents polymorphic subclasses from being copied incompletely via base class interfaces. For the transfer of resources, on the other hand, the move constructor [SWS_CORE_00615] and the move assignment operator with reference qualifier &[SWS_CORE_00616] are publicly available as noexcept=default.
Destruction takes place deterministically via the virtual destructor [SWS_CORE_00617], which is specified as noexcept override=default and ensures the proper cleanup of derived instances. Concurrent read accesses to the methods as well as instantiation are designated as thread-safe [SWS_CORE_00611], [SWS_CORE_00612], [SWS_CORE_00613].
Usage Path
The regular sequence extends from error detection and raising the exception to structured diagnostics in the exception handler:
Creation and throwing: A component detects an error condition, instantiates the exception with the appropriate ErrorCode[SWS_CORE_00611], and throws the object via throw.
Catching: A higher-level block catches the object by reference (for example as const ara::core::Exception& or polymorphically as const std::exception&).
Standardized text output: A textual explanation can be obtained as a null-terminated string via what()[SWS_CORE_00612]. All lifetime guarantees of std::exception::what remain fully preserved.
Detailed error inspection: Via the member function Error(), the handler accesses a const reference to the embedded ErrorCode[SWS_CORE_00613] in order to evaluate system-specific error domains and codes automatically.
Lifetime conditions: The reference provided by Error() binds to the exception object [SWS_CORE_00613]; it must not be used beyond the lifetime of Exception. The lifetime rules of the standard library apply to the return value of what()[SWS_CORE_00612].
Prevention of invalid object states: Encapsulating the copy operations in the protected area prevents polymorphic subclasses from inadvertently becoming inconsistent due to slicing [SWS_CORE_00614], [SWS_CORE_00618].
This guide is based on the specification AUTOSAR Adaptive Platform Release R25-11.
Return the explanatory string. This function overrides the virtual function std::exception:: what. All guarantees about the lifetime of the returned pointer that are given for std::exception::what are preserved. ≙ std::exception::
Return the explanatory string. This function overrides the virtual function std::exception:: what. All guarantees about the lifetime of the returned pointer that are given for std::exception::what are preserved.
AI-GENERATEDunreviewedModel: gemini-3.8-flash-medium · Effort: medium · Temperature: not controllable · Prompt: 1b4e9bb17f9aProvenance
translated from the German guidegemini-3.8-flash-low · 2026-10-13 · German original
The member function what of class ara::core::Exception is used for synchronously retrieving an explanatory string regarding the occurred error [SWS_CORE_00612]. It overrides the virtual function std::exception::what and returns a pointer to a null-terminated string (const char*) [SWS_CORE_00612].
Usage and lifetime
The function expects no input parameters. With regard to the validity of the returned pointer, all guarantees that apply to std::exception::what are preserved [SWS_CORE_00612]. To be able to use the function, the header file ara/core/exception.h must be included [SWS_CORE_00612].
Error Handling and Concurrency
Exception safety: The operation is declared as noexcept and specified as exception-safe (exception safe); it throws no exceptions itself [SWS_CORE_00612].
Concurrency: The execution is specified as thread-safe (thread-safe) [SWS_CORE_00612]. Calls can thus safely be made from parallel threads.
gemini-3.8-flash-low· 2026-10-13 · German original