captureError method
Implementation
@visibleForTesting
Future<void> captureError(
Hub hub,
SentryOptions options,
Object exception,
StackTrace stackTrace,
) async {
options.logger(
SentryLevel.error,
'Uncaught zone error',
logger: 'sentry.runZonedGuarded',
exception: exception,
stackTrace: stackTrace,
);
// runZonedGuarded doesn't crash the app, but is not handled by the user.
final mechanism = Mechanism(type: 'runZonedGuarded', handled: false);
final throwableMechanism = ThrowableMechanism(mechanism, exception);
final event = SentryEvent(
throwable: throwableMechanism,
level: options.markAutomaticallyCollectedErrorsAsFatal
? SentryLevel.fatal
: SentryLevel.error,
timestamp: hub.options.clock(),
);
// marks the span status if none to `internal_error` in case there's an
// unhandled error
hub.configureScope(
(scope) => scope.span?.status ??= const SpanStatus.internalError(),
);
await hub.captureEvent(event, stackTrace: stackTrace);
}