From a1ce17d675bc3970879c4f308d64efe728005538 Mon Sep 17 00:00:00 2001 From: Vadim <44135514+vodemn@users.noreply.github.com> Date: Tue, 13 Feb 2024 19:33:40 +0100 Subject: [PATCH] ML-154 Improved EXIF errors reporting (#159) * removed unused analytics event & added `logCrash` * added analytics to `RemoteConfigService` * run app with `runZonedGuarded` * added crash logging to `CameraContainerBloc` * log product id for IAP errors * typo * log crashes in `RemoteConfigService` * ignore silent `FlutterError` * fixed `evFromImage` test * fixed `showBuyProDialog` test * log errors in console * depend on iap 0.7.2 * Made errors non-fatal by default * improved EXIF errors reporting * fixed tests --- lib/utils/ev_from_bytes.dart | 9 ++++++++- test/utils/ev_from_bytes_test.dart | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/utils/ev_from_bytes.dart b/lib/utils/ev_from_bytes.dart index c7c7b63..553702d 100644 --- a/lib/utils/ev_from_bytes.dart +++ b/lib/utils/ev_from_bytes.dart @@ -10,7 +10,14 @@ Future evFromImage(Uint8List bytes) async { final apertureValueRatio = (tags["EXIF FNumber"]?.values as IfdRatios?)?.ratios.first; final speedValueRatio = (tags["EXIF ExposureTime"]?.values as IfdRatios?)?.ratios.first; if (iso == null || apertureValueRatio == null || speedValueRatio == null) { - throw FlutterError('Error parsing EXIF: ${tags.keys}'); + throw ArgumentError( + 'Error parsing EXIF: ${tags.keys.join(', ')}', + [ + if (iso == null) 'EXIF ISOSpeedRatings', + if (apertureValueRatio == null) 'EXIF FNumber', + if (speedValueRatio == null) 'EXIF ExposureTime', + ].join(', '), + ); } final aperture = apertureValueRatio.numerator / apertureValueRatio.denominator; diff --git a/test/utils/ev_from_bytes_test.dart b/test/utils/ev_from_bytes_test.dart index 635bb3c..488d77e 100644 --- a/test/utils/ev_from_bytes_test.dart +++ b/test/utils/ev_from_bytes_test.dart @@ -17,7 +17,7 @@ void main() { 'no EXIF', () { final bytes = File('assets/launcher_icon_dev_512.png').readAsBytesSync(); - expectLater(evFromImage(bytes), throwsFlutterError); + expectLater(evFromImage(bytes), throwsArgumentError); }, ); });