Serves as a thread-safe exception for signaling and propagating UDS NRC errors in diagnostic classes.
AI-GENERATEDunreviewedModel: gemini-3.8-flash-medium · Effort: medium · Temperature: not controllable · Prompt: 6ef167bbc303ProvenanceOpen questions (2)
translated from the German guidegemini-3.8-flash-low · 2026-10-13 · German original
Serves as a thread-safe exception for signaling and propagating UDS NRC errors in diagnostic classes.
The class ara::diag::DiagUdsNrcException serves as a standardized exception for signaling UDS NRC errors by diagnostic classes of the AUTOSAR Adaptive Platform (AUTOSAR_AP_SWS_Diagnostics §8.12.4 “Class: DiagUdsNrcException”). When a corresponding error condition occurs, it is instantiated with a ara::core::ErrorCode, thrown, and caught by the calling application for error handling. As an essential constraint, its constructor guarantees complete exception safety (noexcept) as well as thread safety according to [SWS_DM_00528], thereby ensuring reliable object creation even in concurrent contexts.
Context
In the AUTOSAR Adaptive Platform, class ara::diag::DiagUdsNrcException forms the central exception type for diagnostic classes of the diag module (AUTOSAR_AP_SWS_Diagnostics §8.12.4 “Class: DiagUdsNrcException”). According to specification [SWS_DM_00527], it defines a standardized C++ exception interface that inherits directly from base exception class ara::core::Exception. Its primary responsibility is to transport error conditions from the diagnostic context, particularly Negative Response Codes (NRC) of the UDS protocol, as typed exceptions across the application programming interface. The class interacts closely with ara::core::ErrorCode, which encapsulates the concrete error code, as well as with calling application layers that make diagnostic requests and must catch any errors ([SWS_DM_00528]). Through declaration in header ara/diag/diag_uds_nrc_error_domain.h, the exception is directly linked to the associated UDS NRC error domain ([SWS_DM_00528]).
The lifecycle of an instance of ara::diag::DiagUdsNrcException begins with its explicit instantiation by a diagnostic class or an internal error-handling routine. According to [SWS_DM_00528], the class provides a constructor explicit DiagUdsNrcException(ara::core::ErrorCode err) noexcept; that accepts the underlying error code as parameter err. This constructor is explicitly defined as exception-safe (exception safe) and non-throwing (noexcept) ([SWS_DM_00528]), which guarantees that no secondary exceptions can occur during object creation in the error path. In addition, creation is classified as thread-safe (thread-safe) according to [SWS_DM_00528]. After creation, the exception instance is typically thrown by value via the C++ runtime system. Ownership of the object remains with the runtime environment during stack unwinding until the exception is bound and evaluated in an appropriate catch block. When leaving the exception-handling block, the lifecycle of the object ends through regular destruction.
Usage Path
The typical usage path comprises the detection of a UDS NRC error, the creation of the exception, and its subsequent evaluation by the application:
An application component invokes a diagnostic function or service interface of a ara::diag class.
During processing, the diagnostic class determines that the request cannot be serviced successfully and a UDS NRC is present, whereupon it creates a corresponding ara::core::ErrorCode.
Passing this error code, exception ara::diag::DiagUdsNrcException is instantiated via its constructor ([SWS_DM_00528]).
The calling application catches the exception either specifically by type as ara::diag::DiagUdsNrcException ([SWS_DM_00527]) or polymorphically via base class ara::core::Exception and accesses the error information.
Since ara::diag::DiagUdsNrcException is itself a vehicle for error signaling, error scenarios primarily relate to robustness and concurrency during exception creation:
Robust object creation: Due to its specification as noexcept and exception safe ([SWS_DM_00528]), throwing a secondary exception during construction is ruled out. This prevents fatal runtime aborts such as std::terminate in critical error-handling paths.
Validity of the error code: As a precondition for instantiation, a valid ara::core::ErrorCode must be available ([SWS_DM_00528]). This typically originates from the error domain defined by ara/diag/diag_uds_nrc_error_domain.h.
Parallel diagnostic processing: Because the constructor is specified as thread-safe ([SWS_DM_00528]), multiple threads may create diagnostic exceptions concurrently without race conditions occurring during initialization of the exception object.
This guide was generated by an AI system based on the AUTOSAR specification R25-11.
UML class diagram
Hohle Dreieckspfeile = Vererbung (zeigt zur Basisklasse); Klicken öffnet die jeweilige Klassenseite.
gemini-3.8-flash-low· 2026-10-13 · German original