Wrap sync-ing attemts inside a try-catch block to avoid uncaught errors

This commit is contained in:
Vishnu Mohandas 2020-06-16 00:08:08 +05:30
parent baeb54f534
commit 4d77ccc8ba

View file

@ -28,8 +28,7 @@ void _main() async {
await Configuration.instance.init();
FavoritePhotosRepository.instance.init();
PhotoSyncManager.instance.sync();
FolderSharingService.instance.sync();
_sync();
final SentryClient sentry = new SentryClient(dsn: SENTRY_DSN);
@ -45,6 +44,15 @@ void _main() async {
);
}
void _sync() async {
try {
await PhotoSyncManager.instance.sync();
await FolderSharingService.instance.sync();
} catch (e) {
logger.warning(e);
}
}
void _sendErrorToSentry(SentryClient sentry, Object error, StackTrace stack) {
logger.shout("Uncaught error", error, stack);
try {
@ -75,8 +83,7 @@ class MyApp extends StatelessWidget with WidgetsBindingObserver {
@override
void didChangeAppLifecycleState(AppLifecycleState state) {
if (state == AppLifecycleState.resumed) {
PhotoSyncManager.instance.sync();
FolderSharingService.instance.sync();
_sync();
}
}
}