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, locality: address.locality,
); );
} }
} catch (exception) { } catch (exception, stack) {
debugPrint('$runtimeType addAddressToMetadata failed with path=$path coordinates=$coordinates exception=$exception'); debugPrint('$runtimeType addAddressToMetadata failed with path=$path coordinates=$coordinates exception=$exception\n$stack');
} }
} }

View file

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