error method
Records an error or a structured event with an error to Sentry.
Errors are logged with their associated stack traces. If an event is provided, additional context is included in the report.
error
- the error to log.
stackTrace
- the stack trace associated with the error.
event
- an optional LogEvent providing additional context for the error.
Implementation
@override
Future<void> error({
dynamic error,
StackTrace? stackTrace,
LogEvent? event,
}) async {
try {
if (shouldLog(event: event)) {
developer.log('Reporting error to Sentry', name: 'SentryLogStrategy');
if (event != null) {
Sentry.captureException(error, stackTrace: stackTrace);
}
}
} catch (e, stack) {
developer.log(
'Error during error handling in Sentry Strategy',
name: 'SentryLogStrategy',
error: e,
stackTrace: stack,
);
}
}