Log some exceptions are warnings

These aren't really a problem, but it's still interesting to know if
they are happening.
This commit is contained in:
Vishesh Handa
2020-05-31 02:00:00 +02:00
parent 6e229aeebd
commit b9b53f28c4
2 changed files with 14 additions and 3 deletions

View File

@ -117,7 +117,7 @@ class NotesCache {
return json.decode(contents).cast<String>();
} catch (ex, st) {
Log.e("Exception - $ex for contents: $contents");
await logException(ex, st);
await logExceptionWarning(ex, st);
return [];
}
}

View File

@ -109,6 +109,15 @@ Future<void> logException(Exception e, StackTrace stackTrace) async {
return FlutterCrashlytics().logException(e, stackTrace);
}
Future<void> logExceptionWarning(Exception e, StackTrace stackTrace) async {
if (!reportCrashes) {
return;
}
await captureSentryException(e, stackTrace, level: SeverityLevel.warning);
return FlutterCrashlytics().logException(e, stackTrace);
}
List<Breadcrumb> breadcrumbs = [];
void captureErrorBreadcrumb({
@ -121,14 +130,16 @@ void captureErrorBreadcrumb({
Future<void> captureSentryException(
Object exception,
StackTrace stackTrace,
) async {
StackTrace stackTrace, {
SeverityLevel level = SeverityLevel.error,
}) async {
try {
final sentry = await getSentryClient();
final Event event = Event(
exception: exception,
stackTrace: stackTrace,
breadcrumbs: breadcrumbs,
level: level,
);
return sentry.capture(event: event);