DEENESPTFRRUARHIKOZHNL

类 ara::diag::DiagReportingException

[SWS_DM_00987] Upstream: RS_AP_00119

class DiagReportingException :              public ara::core::Exception {...};

Exception type thrown by Diag classes.

Header-Datei#include "ara/diag/diag_error_domain.h"
Forwarding-Header#include "ara/diag/diag_fwd.h"
Scopenamespace ara::diag
Basisklasse(n)ara::core::Exception

用户指南人工智能生成

在诊断操作中将错误作为带有错误代码的异常同步指示给调用方。
AI 生成 未审核 模型: gemini-3.8-flash-medium · 推理强度: medium · 温度: 不可控 · 提示词: a149cf644e7f 来源 未决问题(2)
译自德文指南gemini-3.8-flash-low · 2026-10-13 · 德文原文

在诊断操作中将错误作为带有错误代码的异常同步指示给调用方。

异常类 ara::diag::DiagReportingException 用于同步指示在 Adaptive Platform 诊断类内部的操作中发生的错误状态(AUTOSAR_AP_SWS_Diagnostics §8.11.8 “Class: DiagReportingException”)。它显式地使用特定的 ara::core::ErrorCode 进行实例化,并将其传递给调用方应用程序以进行错误原因分析 [SWS_DM_00988]。作为关键约束条件,其构造函数被指定为 noexcept、异常安全(exception safe)且线程安全(thread-safe),从而保证了即使在并发执行上下文中也能实现无差错的对象创建。必须避免未处理的实例,因为它们会导致程序立即终止。

上下文

类 ara::diag::DiagReportingException 构成了诊断功能集群内部报告和通知操作的核心异常类(AUTOSAR_AP_SWS_Diagnostics §8.11.8 “Class: DiagReportingException”)。它被定义为 ara::core::Exception 的公有特化,并表示在与诊断类交互期间出现的特定错误状态 [SWS_DM_00987]。在 AUTOSAR Adaptive 应用程序中,该异常充当内部诊断服务与调用方应用程序软件之间的纽带:如果在诊断报告期间发生错误,DiagReportingException 将封装该状态并通过调用栈同步传递给调用方。主要交互对象包括模块 diag 中与诊断相关的 API 类(它们在发生错误时实例化并抛出异常),以及应用程序中捕获并处理诊断错误的上层错误处理例程。

生命周期

ara::diag::DiagReportingException 的实例化显式地通过向构造函数 [SWS_DM_00988] 传递类型为 ara::core::ErrorCode 的错误代码来完成。构造函数声明为 explicit 可防止错误代码隐式转换为异常对象,并确保异常实例始终是被有意识地创建的 [SWS_DM_00988]。

由于构造函数带有规范 noexcept,因此保证了在对象创建本身过程中不会发生进一步的异常 [SWS_DM_00988]。这对于错误路径至关重要,以防止在错误处理期间发生异常级联。此外,构造过程被明确归类为异常安全(exception safe)和线程安全(thread-safe)[SWS_DM_00988]。因此,多个线程可以并发且无相互阻塞地创建独立的异常对象。

该异常的生命周期与 C++ 栈展开绑定:在调用栈上创建后,对象通过 throw 机制传播到负责的 catch 块。离开异常处理程序后,该对象的生命周期结束,占用的资源将自动释放。

使用路径

常规使用路径在 Adaptive 平台内的诊断报告或操作失败时启动。在典型流程中,执行操作的诊断类检测到不允许的条件并生成匹配的 ara::core::ErrorCode。在同步异常路径中,不再仅仅将错误作为返回值传递,而是构造并抛出一个类型为 ara::diag::DiagReportingException 的对象 [SWS_DM_00987]。

使用 DiagReportingException 的异常处理应用ara::diag KomponenteDiagReportingExceptionDiagnoseoperation aufrufenFehlerzustand erkennenara::core::ErrorCode erzeugen使用 ErrorCode 构造抛出异常(throw)catch (const DiagReportingException&)Fehlercode auswerten

时序图:使用 DiagReportingException 进行异常创建和错误处理的典型流程。来源:[SWS_DM_00987]、[SWS_DM_00988]、AUTOSAR_AP_SWS_Diagnostics §8.11.8 “Class: DiagReportingException”。

在接收端,应用逻辑捕获该异常。这优选通过对常量对象的引用(const ara::diag::DiagReportingException& 或多态地通过 const ara::core::Exception&)来实现。随后,处理程序提取嵌入的 ara::core::ErrorCode,以确定确切的错误原因并启动针对具体情况的恢复措施。

错误场景

与 ara::diag::DiagReportingException 相关的错误场景主要涉及所传递错误数据的解释以及缺乏正确的异常处理。

构造函数强制要求一个有效的 ara::core::ErrorCode [SWS_DM_00988]。通过包含头文件 ara/diag/diag_error_domain.h [SWS_DM_00988],传入的错误代码推测主要源自特定的诊断错误域。 问题 Q-cb8a197542857807 (未决)应用程序架构中的一个主要错误场景在于对异常的捕获不完整:如果沿调用栈抛出的 DiagReportingException 未被匹配的 catch 块处理,将不可避免地导致调用 std::terminate,从而引起相应平台进程的崩溃。由于构造函数本身声明为 noexcept [SWS_DM_00988],因此异常的实例化不会因内部资源匮乏而失败。因此,开发人员必须确保调用组件针对 DiagReportingException 的出现做好了准备,特别是在使用通过异常而非 ara::core::Result 指示错误的 API 时。

本指南由 AI 基于 AUTOSAR Adaptive R25-11 规范生成。

UML 类图

Hohle Dreieckspfeile = Vererbung (zeigt zur Basisklasse); Klicken öffnet die jeweilige Klassenseite.

G nara__diag__DiagReportingException911 DiagReportingException + DiagReportingException() nara__core__Exception792 Exception nara__diag__DiagReportingException911->nara__core__Exception792 nstd__exception10 std::exception nara__core__Exception792->nstd__exception10

构造函数和析构函数

Construct a new DiagException from an ErrorCode.

explicit DiagReportingException (ara::core::ErrorCode err) noexcept;

方法文档

函数 DiagReportingException [SWS_DM_00988] Upstream: RS_AP_00119

explicit DiagReportingException (ara::core::ErrorCode err) noexcept;

Construct a new DiagException from an ErrorCode.

Header-Datei#include "ara/diag/diag_error_domain.h"
Scopeclass ara::diag::DiagReportingException
Exception-Sicherheitexception safe
Thread-Sicherheitthread-safe

Parameter (in)

ParameterBeschreibung
errthe ErrorCode

Request a governed re-review of this record. The record is not changed immediately.

Record
AUTOSAR/AP/record/SWS_DM_00988
Status
valid/unmigrated
Version
AUTOSAR/AP/record/SWS_DM_00988@rel:R25-11#2627ae1d
Content hash
2627ae1d
Source
https://www.autosar.org/fileadmin/standards/R25-11/AP/AUTOSAR_AP_SWS_Diagnostics.pdf#nameddest=SWS_DM_00988
Status: valid/unmigrated Version: rel:R25-11#9465de9a Versionshistorie & Revisions (1 transition, 4 revision)
Current State
valid/unmigrated
Reason
mechanically backfilled by migriere_status_backfill.py -- no per-field curation history exists yet for this record
Campaign
2026-08-13-status-backfill
Active Version
AUTOSAR/AP/record/SWS_DM_00988@rel:R25-11#9465de9a
Point-in-Time History:
Recorded Revisions (4):
  • R25-11rel:R25-11#431097f22026-09-30
  • R23-11rel:R23-11#85d295e12026-10-14
  • R24-11rel:R24-11#9465de9a2026-10-14
  • R25-11rel:R25-11#9465de9a2026-10-14 active
DateActorTransitionReason / RationaleCampaign
2026-08-13toolnone → valid/unmigratedmechanically backfilled by migriere_status_backfill.py -- no per-field curation history exists yet for this record2026-08-13-status-backfill