veApmExceptionHandler function

void veApmExceptionHandler(
  1. Object exception,
  2. StackTrace stack
)

Implementation

void veApmExceptionHandler(Object exception, StackTrace stack) {
  if (exception is ApmNetworkError) {
    // 与原生对齐:网络异常不走异常上报,不参与应用的异常率计算。
    // 网络异常在发生异常[_HttpRecorderImpl#onError]时,就已经上报过了。所以这里直接返回。
    logRelease('method: runTraceApp, step: ApmNetworkError return');
    return;
  }
  FlutterErrorDetails error;
  if (exception is FlutterErrorDetails) {
    error = exception;
    if (error.stack == null) {
      error = error.copyWith(stack: stack);
    }
  } else {
    error = FlutterErrorDetails(
      exception: exception,
      stack: stack,
      context: ErrorDescription(exception.toString()),
    );
  }
  logRelease('method: runTraceApp, step: ApmErrorTrace.recordError');
  ApmErrorTrace.instance.recordError(error);
}