From 85a1ebf8b434965487164d13ea84af38270aa1a8 Mon Sep 17 00:00:00 2001 From: Thibault Deckers Date: Tue, 9 Jun 2020 09:42:25 +0900 Subject: [PATCH] safer service call --- lib/model/image_entry.dart | 4 ++-- lib/services/service_policy.dart | 7 +++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/model/image_entry.dart b/lib/model/image_entry.dart index cb7911923..845dec9dc 100644 --- a/lib/model/image_entry.dart +++ b/lib/model/image_entry.dart @@ -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'); } } diff --git a/lib/services/service_policy.dart b/lib/services/service_policy.dart index 0fb47929c..a1650ce19 100644 --- a/lib/services/service_policy.dart +++ b/lib/services/service_policy.dart @@ -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();