logError method
Future<void>
logError(
- dynamic error, {
- StackTrace? stackTrace,
- String reason = '',
- List<
String> tags = const [],
override
Implementation
@override
Future<void> logError(
dynamic error, {
StackTrace? stackTrace,
String reason = '',
List<String> tags = const [],
}) async {
if (isReady) {
try {
// Capture as a Sentry Issue (shows in Issues section with full stack trace).
await Sentry.captureException(
error,
stackTrace: stackTrace,
withScope: (scope) {
if (reason.isNotEmpty) {
scope.setContexts('error_context', {'reason': reason});
}
for (int i = 0; i < tags.length; i++) {
scope.setTag('tag_$i', tags[i]);
}
},
);
// Also send to Sentry Logs section for visibility in the log stream.
if (Sentry.isEnabled) {
Sentry.logger.error(reason.isNotEmpty ? reason : error?.toString() ?? 'error');
}
} catch (e) {
_printDebug(
'$providerName: Failed to log error: $e, trace: ${StackTrace.current}',
);
}
}
}