recordError method

  1. @override
Future<void> recordError(
  1. dynamic exception,
  2. StackTrace? stack, {
  3. dynamic reason,
  4. Iterable<Object> information = const [],
  5. bool fatal = false,
})
override

Logs a custom error with an optional stack trace and reason.

Implementation

@override
Future<void> recordError(
  dynamic exception,
  StackTrace? stack, {
  dynamic reason,
  Iterable<Object> information = const [],
  bool fatal = false,
}) async {
  await Sentry.captureException(
    exception,
    stackTrace: stack,
    hint: reason,
    withScope: (scope) {
      if (fatal) {
        scope.level = SentryLevel.fatal;
      }
      if (information.isNotEmpty) {
        scope.setContexts('information', {'data': information.toList()});
      }
    },
  );
}