上一主题: 定义新错误类型下一主题: MethodCalledErrorReporter


ExceptionErrorReporter

ExceptionErrorReporter 跟踪器可用于检查从已检测的方法抛出的异常。 如果抛出了异常,此跟踪器会将异常当作错误,并从异常中获取错误消息。 这是对错误的最常见定义。

为了捕获错误消息,ExceptionErrorReporter 跟踪器必须与 "...WithParameters" 指令配合使用。 例如:

TraceOneMethodWithParametersOfClass: com.bank.CustomerAccount getBalance ExceptionErrorReporter "CustomerAccount:Errors Per Interval"

此指令指定从 CustomerAccount 上的 getBalance() 方法抛出的任何异常均视为错误。

请注意,您必须使用“...WithParameters”指令增加“每个时间间隔的错误”度量标准,但对于任一方法,您只需指定“...WithParameters”指令一次,该方法上的参数即可对所有追踪器可用。 例如,您可以指定:

TraceOneMethodWithParametersOfClass: com.myClass myMethod BlamePointTracer

此指令使 com.myClass myMethod 方法的参数可用于其他追踪器,包括 ExceptionErrorReporter 追踪器。