Catch any errors that might happen when calling handleUpdateExerciseFromApi

This seems to mostly happen when the app is running (or is moved) to the background
This commit is contained in:
Roland Geider
2026-04-09 13:53:25 +02:00
parent 0e16ef5163
commit a8071c3532

View File

@@ -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 {