logException: Also log to Sentry

This commit is contained in:
Vishesh Handa
2020-04-17 09:41:36 +02:00
parent 98b8e92437
commit 6c47016c8b
4 changed files with 24 additions and 3 deletions

View File

@ -107,3 +107,21 @@ Future<void> reportError(Object error, StackTrace stackTrace) async {
print("Uncaught Exception: $error");
print(stackTrace);
}
Future<void> logException(Exception e, StackTrace stackTrace) async {
if (!reportCrashes) {
return;
}
try {
final sentry = await getSentryClient();
await sentry.captureException(
exception: e,
stackTrace: stackTrace,
);
} catch (e) {
print("Failed to report with Sentry: $e");
}
return FlutterCrashlytics().logException(e, stackTrace);
}