safer service call

This commit is contained in:
Thibault Deckers 2020-06-09 09:42:25 +09:00
parent 4dd5e9a3b8
commit 85a1ebf8b4
2 changed files with 7 additions and 4 deletions

View file

@ -279,8 +279,8 @@ class ImageEntry {
locality: address.locality,
);
}
} catch (exception) {
debugPrint('$runtimeType addAddressToMetadata failed with path=$path coordinates=$coordinates exception=$exception');
} catch (exception, stack) {
debugPrint('$runtimeType addAddressToMetadata failed with path=$path coordinates=$coordinates exception=$exception\n$stack');
}
}

View file

@ -30,8 +30,11 @@ class ServicePolicy {
task ??= _Task(
() async {
if (debugLabel != null) debugPrint('$runtimeType $debugLabel start');
final result = await platformCall();
completer.complete(result);
try {
completer.complete(await platformCall());
} catch (error, stackTrace) {
completer.completeError(error, stackTrace);
}
if (debugLabel != null) debugPrint('$runtimeType $debugLabel completed');
_running = null;
_pickNext();