fatal method

  1. @override
Future<void> fatal({
  1. dynamic error,
  2. StackTrace? stackTrace,
  3. LogEvent? event,
})
override

Marks an error as fatal and records it to Sentry.

Fatal errors are treated as critical failures that should be prominently flagged in Sentry. Additional context can be provided through a LogEvent.

error - the critical error to log. stackTrace - the stack trace associated with the critical error. event - an optional LogEvent providing additional context for the critical error.

Implementation

@override
Future<void> fatal(
    {dynamic error, StackTrace? stackTrace, LogEvent? event}) async {
  try {
    if (shouldLog(event: event)) {
      developer.log(
        'Recording fatal error to Sentry',
        name: 'SentryLogStrategy',
      );
      if (event != null) {
        Sentry.captureException(error, stackTrace: stackTrace);
      }
    }
  } catch (e, stack) {
    developer.log(
      'Error during fatal error handling in Sentry Strategy',
      name: 'SentryLogStrategy',
      error: e,
      stackTrace: stack,
    );
  }
}