reportError static method
Implementation
static Future<void> reportError(Object error, StackTrace stackTrace,
{dynamic data, String? dsn}) async {
if (UtilsPlatform.isDebug) {
// In development mode, simply print to console.
// Print the full stacktrace in debug mode.
print(error);
print(stackTrace);
return;
} else {
try {
final SentryClient sentry =
new SentryClient(SentryOptions(dsn: dsn ?? UtilsSentry.dsn));
final SentryEvent event = await getSentryEnvEvent(error);
if (event.extra != null) {
event.extra!['json'] = data;
}
print('Sending report to sentry.io ${stackTrace.toString()}');
await sentry.captureEvent(event, stackTrace: stackTrace);
} catch (e) {
print('Sending report to sentry.io failed: $e');
print('Original error: $error');
}
}
}