Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

mob/photos: log unhandled errors

Neeraj Gupta719538f4801b
diff --git a/mobile/apps/photos/lib/core/error-reporting/super_logging.dart b/mobile/apps/photos/lib/core/error-reporting/super_logging.dart
index 85b8b72263..4f62860c97 100644
--- a/mobile/apps/photos/lib/core/error-reporting/super_logging.dart
+++ b/mobile/apps/photos/lib/core/error-reporting/super_logging.dart
@@ -266,13 +266,41 @@ class SuperLogging {
return event;
};
},
- appRunner: () => appConfig!.body!(),
+ appRunner: () => _runWithUnhandledErrorLogging(appConfig!.body!),
);
} else {
- await appConfig.body!();
+ await _runWithUnhandledErrorLogging(appConfig.body!);
}
}
+ static Future<void> _runWithUnhandledErrorLogging(
+ FutureOrVoidCallback body,
+ ) async {
+ final previousFlutterError = FlutterError.onError;
+ FlutterError.onError = (details) {
+ previousFlutterError?.call(details);
+ $.severe(
+ "Unhandled Flutter error",
+ details.exception,
+ details.stack,
+ );
+ };
+ WidgetsBinding.instance.platformDispatcher.onError = (
+ Object error,
+ StackTrace stack,
+ ) {
+ $.severe("Unhandled platform error", error, stack);
+ return false;
+ };
+
+ await runZonedGuarded(
+ () async => body(),
+ (Object error, StackTrace stack) {
+ $.severe("Unhandled zone error", error, stack);
+ },
+ );
+ }
+
static Future<void> setUserID(String userID) async {
if (config.sentryDsn != null) {
$.finest("setting sentry user ID to: $userID");