diff --git a/lib/providers/exercises.dart b/lib/providers/exercises.dart index 975147f8b..bf0889b2d 100644 --- a/lib/providers/exercises.dart +++ b/lib/providers/exercises.dart @@ -314,14 +314,21 @@ class ExercisesProvider with ChangeNotifier { // Note: no await since we don't care for the updated data right now. It // will be written to the db whenever the request finishes and we will get // the updated exercise the next time - handleUpdateExerciseFromApi(database, exerciseId).then( - (_) {}, - onError: (error, stackTrace) => _logger.info( - 'Error while calling unawaited handleUpdateExerciseFromApi', - error, - stackTrace, - ), - ); + try { + handleUpdateExerciseFromApi(database, exerciseId).then( + (_) {}, + onError: (error, stackTrace) => _logger.info( + 'Error while calling unawaited handleUpdateExerciseFromApi', + error, + stackTrace, + ), + ); + } catch (e) { + // This is here just to catch any errors that seem to happen when the app is running + // in the background: https://github.com/wger-project/wger/issues/2206 + + _logger.info('Error while calling handleUpdateExerciseFromApi:', e); + } return exercise; } on NoSuchEntryException {