From ffc7643adf2b881510170801f0a260b8c508d858 Mon Sep 17 00:00:00 2001 From: Thibault Deckers Date: Mon, 9 Aug 2021 19:32:32 +0900 Subject: [PATCH] simplified platform exception reporting --- lib/services/android_app_service.dart | 36 ++++++++--------- lib/services/android_debug_service.dart | 52 ++++++++++++------------- lib/services/app_shortcut_service.dart | 8 ++-- lib/services/device_service.dart | 4 +- lib/services/embedded_data_service.dart | 16 ++++---- lib/services/geocoding_service.dart | 4 +- lib/services/global_search.dart | 4 +- lib/services/image_file_service.dart | 48 +++++++++++------------ lib/services/media_store_service.dart | 12 +++--- lib/services/metadata_service.dart | 24 ++++++------ lib/services/report_service.dart | 4 -- lib/services/storage_service.dart | 48 +++++++++++------------ lib/services/time_service.dart | 4 +- lib/services/viewer_service.dart | 8 ++-- lib/services/window_service.dart | 20 +++++----- 15 files changed, 144 insertions(+), 148 deletions(-) diff --git a/lib/services/android_app_service.dart b/lib/services/android_app_service.dart index d8b8dbf72..20514f4ca 100644 --- a/lib/services/android_app_service.dart +++ b/lib/services/android_app_service.dart @@ -21,8 +21,8 @@ class AndroidAppService { kakaoTalk.ownedDirs.add('KakaoTalkDownload'); } return packages; - } on PlatformException catch (e) { - await reportService.recordChannelError('getPackages', e); + } on PlatformException catch (e, stack) { + await reportService.recordError(e, stack); } return {}; } @@ -34,8 +34,8 @@ class AndroidAppService { 'sizeDip': size, }); if (result != null) return result as Uint8List; - } on PlatformException catch (e) { - await reportService.recordChannelError('getAppIcon', e); + } on PlatformException catch (e, stack) { + await reportService.recordError(e, stack); } return Uint8List(0); } @@ -47,8 +47,8 @@ class AndroidAppService { 'label': label, }); if (result != null) return result as bool; - } on PlatformException catch (e) { - await reportService.recordChannelError('copyToClipboard', e); + } on PlatformException catch (e, stack) { + await reportService.recordError(e, stack); } return false; } @@ -60,8 +60,8 @@ class AndroidAppService { 'mimeType': mimeType, }); if (result != null) return result as bool; - } on PlatformException catch (e) { - await reportService.recordChannelError('edit', e); + } on PlatformException catch (e, stack) { + await reportService.recordError(e, stack); } return false; } @@ -73,8 +73,8 @@ class AndroidAppService { 'mimeType': mimeType, }); if (result != null) return result as bool; - } on PlatformException catch (e) { - await reportService.recordChannelError('open', e); + } on PlatformException catch (e, stack) { + await reportService.recordError(e, stack); } return false; } @@ -89,8 +89,8 @@ class AndroidAppService { 'geoUri': geoUri, }); if (result != null) return result as bool; - } on PlatformException catch (e) { - await reportService.recordChannelError('openMap', e); + } on PlatformException catch (e, stack) { + await reportService.recordError(e, stack); } return false; } @@ -102,8 +102,8 @@ class AndroidAppService { 'mimeType': mimeType, }); if (result != null) return result as bool; - } on PlatformException catch (e) { - await reportService.recordChannelError('setAs', e); + } on PlatformException catch (e, stack) { + await reportService.recordError(e, stack); } return false; } @@ -117,8 +117,8 @@ class AndroidAppService { 'urisByMimeType': urisByMimeType, }); if (result != null) return result as bool; - } on PlatformException catch (e) { - await reportService.recordChannelError('shareEntries', e); + } on PlatformException catch (e, stack) { + await reportService.recordError(e, stack); } return false; } @@ -131,8 +131,8 @@ class AndroidAppService { }, }); if (result != null) return result as bool; - } on PlatformException catch (e) { - await reportService.recordChannelError('shareSingle', e); + } on PlatformException catch (e, stack) { + await reportService.recordError(e, stack); } return false; } diff --git a/lib/services/android_debug_service.dart b/lib/services/android_debug_service.dart index ae063ac12..d106669a3 100644 --- a/lib/services/android_debug_service.dart +++ b/lib/services/android_debug_service.dart @@ -9,40 +9,40 @@ class AndroidDebugService { static Future crash() async { try { await platform.invokeMethod('crash'); - } on PlatformException catch (e) { - await reportService.recordChannelError('crash', e); + } on PlatformException catch (e, stack) { + await reportService.recordError(e, stack); } } static Future exception() async { try { await platform.invokeMethod('exception'); - } on PlatformException catch (e) { - await reportService.recordChannelError('exception', e); + } on PlatformException catch (e, stack) { + await reportService.recordError(e, stack); } } static Future safeException() async { try { await platform.invokeMethod('safeException'); - } on PlatformException catch (e) { - await reportService.recordChannelError('safeException', e); + } on PlatformException catch (e, stack) { + await reportService.recordError(e, stack); } } static Future exceptionInCoroutine() async { try { await platform.invokeMethod('exceptionInCoroutine'); - } on PlatformException catch (e) { - await reportService.recordChannelError('exceptionInCoroutine', e); + } on PlatformException catch (e, stack) { + await reportService.recordError(e, stack); } } static Future safeExceptionInCoroutine() async { try { await platform.invokeMethod('safeExceptionInCoroutine'); - } on PlatformException catch (e) { - await reportService.recordChannelError('safeExceptionInCoroutine', e); + } on PlatformException catch (e, stack) { + await reportService.recordError(e, stack); } } @@ -50,8 +50,8 @@ class AndroidDebugService { try { final result = await platform.invokeMethod('getContextDirs'); if (result != null) return result as Map; - } on PlatformException catch (e) { - await reportService.recordChannelError('getContextDirs', e); + } on PlatformException catch (e, stack) { + await reportService.recordError(e, stack); } return {}; } @@ -60,8 +60,8 @@ class AndroidDebugService { try { final result = await platform.invokeMethod('getEnv'); if (result != null) return result as Map; - } on PlatformException catch (e) { - await reportService.recordChannelError('getEnv', e); + } on PlatformException catch (e, stack) { + await reportService.recordError(e, stack); } return {}; } @@ -73,8 +73,8 @@ class AndroidDebugService { 'uri': entry.uri, }); if (result != null) return result as Map; - } on PlatformException catch (e) { - await reportService.recordChannelError('getBitmapFactoryInfo', e); + } on PlatformException catch (e, stack) { + await reportService.recordError(e, stack); } return {}; } @@ -87,8 +87,8 @@ class AndroidDebugService { 'uri': entry.uri, }); if (result != null) return result as Map; - } on PlatformException catch (e) { - await reportService.recordChannelError('getContentResolverMetadata', e); + } on PlatformException catch (e, stack) { + await reportService.recordError(e, stack); } return {}; } @@ -102,8 +102,8 @@ class AndroidDebugService { 'sizeBytes': entry.sizeBytes, }); if (result != null) return result as Map; - } on PlatformException catch (e) { - await reportService.recordChannelError('getExifInterfaceMetadata', e); + } on PlatformException catch (e, stack) { + await reportService.recordError(e, stack); } return {}; } @@ -115,8 +115,8 @@ class AndroidDebugService { 'uri': entry.uri, }); if (result != null) return result as Map; - } on PlatformException catch (e) { - await reportService.recordChannelError('getMediaMetadataRetrieverMetadata', e); + } on PlatformException catch (e, stack) { + await reportService.recordError(e, stack); } return {}; } @@ -130,8 +130,8 @@ class AndroidDebugService { 'sizeBytes': entry.sizeBytes, }); if (result != null) return result as Map; - } on PlatformException catch (e) { - await reportService.recordChannelError('getMetadataExtractorSummary', e); + } on PlatformException catch (e, stack) { + await reportService.recordError(e, stack); } return {}; } @@ -144,8 +144,8 @@ class AndroidDebugService { 'uri': entry.uri, }); if (result != null) return result as Map; - } on PlatformException catch (e) { - await reportService.recordChannelError('getTiffStructure', e); + } on PlatformException catch (e, stack) { + await reportService.recordError(e, stack); } return {}; } diff --git a/lib/services/app_shortcut_service.dart b/lib/services/app_shortcut_service.dart index 90fb1a102..80a5b82b0 100644 --- a/lib/services/app_shortcut_service.dart +++ b/lib/services/app_shortcut_service.dart @@ -23,8 +23,8 @@ class AppShortcutService { _canPin = result; return result; } - } on PlatformException catch (e) { - await reportService.recordChannelError('canPin', e); + } on PlatformException catch (e, stack) { + await reportService.recordError(e, stack); } return false; } @@ -49,8 +49,8 @@ class AppShortcutService { 'iconBytes': iconBytes, 'filters': filters.map((filter) => filter.toJson()).toList(), }); - } on PlatformException catch (e) { - await reportService.recordChannelError('pin', e); + } on PlatformException catch (e, stack) { + await reportService.recordError(e, stack); } } } diff --git a/lib/services/device_service.dart b/lib/services/device_service.dart index 82ba698f6..725d8577d 100644 --- a/lib/services/device_service.dart +++ b/lib/services/device_service.dart @@ -9,8 +9,8 @@ class DeviceService { await platform.invokeMethod('getPerformanceClass'); final result = await platform.invokeMethod('getPerformanceClass'); if (result != null) return result as int; - } on PlatformException catch (e) { - await reportService.recordChannelError('getPerformanceClass', e); + } on PlatformException catch (e, stack) { + await reportService.recordError(e, stack); } return 0; } diff --git a/lib/services/embedded_data_service.dart b/lib/services/embedded_data_service.dart index 4a2276dfb..0f2b3af82 100644 --- a/lib/services/embedded_data_service.dart +++ b/lib/services/embedded_data_service.dart @@ -26,8 +26,8 @@ class PlatformEmbeddedDataService implements EmbeddedDataService { 'sizeBytes': entry.sizeBytes, }); if (result != null) return (result as List).cast(); - } on PlatformException catch (e) { - await reportService.recordChannelError('getExifThumbnail', e); + } on PlatformException catch (e, stack) { + await reportService.recordError(e, stack); } return []; } @@ -42,8 +42,8 @@ class PlatformEmbeddedDataService implements EmbeddedDataService { 'displayName': '${entry.bestTitle} • Video', }); if (result != null) return result as Map; - } on PlatformException catch (e) { - await reportService.recordChannelError('extractMotionPhotoVideo', e); + } on PlatformException catch (e, stack) { + await reportService.recordError(e, stack); } return {}; } @@ -56,8 +56,8 @@ class PlatformEmbeddedDataService implements EmbeddedDataService { 'displayName': '${entry.bestTitle} • Cover', }); if (result != null) return result as Map; - } on PlatformException catch (e) { - await reportService.recordChannelError('extractVideoEmbeddedPicture', e); + } on PlatformException catch (e, stack) { + await reportService.recordError(e, stack); } return {}; } @@ -74,8 +74,8 @@ class PlatformEmbeddedDataService implements EmbeddedDataService { 'propMimeType': propMimeType, }); if (result != null) return result as Map; - } on PlatformException catch (e) { - await reportService.recordChannelError('extractXmpDataProp', e); + } on PlatformException catch (e, stack) { + await reportService.recordError(e, stack); } return {}; } diff --git a/lib/services/geocoding_service.dart b/lib/services/geocoding_service.dart index e993e64a5..2e41263fe 100644 --- a/lib/services/geocoding_service.dart +++ b/lib/services/geocoding_service.dart @@ -20,8 +20,8 @@ class GeocodingService { 'maxResults': 2, }); return (result as List).cast().map((map) => Address.fromMap(map)).toList(); - } on PlatformException catch (e) { - await reportService.recordChannelError('getAddress', e); + } on PlatformException catch (e, stack) { + await reportService.recordError(e, stack); } return []; } diff --git a/lib/services/global_search.dart b/lib/services/global_search.dart index 055af0e5c..c4a785196 100644 --- a/lib/services/global_search.dart +++ b/lib/services/global_search.dart @@ -14,8 +14,8 @@ class GlobalSearch { await platform.invokeMethod('registerCallback', { 'callbackHandle': PluginUtilities.getCallbackHandle(_init)?.toRawHandle(), }); - } on PlatformException catch (e) { - await reportService.recordChannelError('registerCallback', e); + } on PlatformException catch (e, stack) { + await reportService.recordError(e, stack); } } } diff --git a/lib/services/image_file_service.dart b/lib/services/image_file_service.dart index 870f42468..be7749814 100644 --- a/lib/services/image_file_service.dart +++ b/lib/services/image_file_service.dart @@ -124,8 +124,8 @@ class PlatformImageFileService implements ImageFileService { 'mimeType': mimeType, }) as Map; return AvesEntry.fromMap(result); - } on PlatformException catch (e) { - await reportService.recordChannelError('getEntry', e); + } on PlatformException catch (e, stack) { + await reportService.recordError(e, stack); } return null; } @@ -188,8 +188,8 @@ class PlatformImageFileService implements ImageFileService { cancelOnError: true, ); return completer.future; - } on PlatformException catch (e) { - reportService.recordChannelError('getImage', e); + } on PlatformException catch (e, stack) { + reportService.recordError(e, stack); } return Future.sync(() => Uint8List(0)); } @@ -223,8 +223,8 @@ class PlatformImageFileService implements ImageFileService { 'imageHeight': imageSize.height.toInt(), }); if (result != null) return result as Uint8List; - } on PlatformException catch (e) { - await reportService.recordChannelError('getRegion', e); + } on PlatformException catch (e, stack) { + await reportService.recordError(e, stack); } return Uint8List(0); }, @@ -260,8 +260,8 @@ class PlatformImageFileService implements ImageFileService { 'defaultSizeDip': thumbnailDefaultSize, }); if (result != null) return result as Uint8List; - } on PlatformException catch (e) { - await reportService.recordChannelError('getThumbnail', e); + } on PlatformException catch (e, stack) { + await reportService.recordError(e, stack); } return Uint8List(0); }, @@ -274,8 +274,8 @@ class PlatformImageFileService implements ImageFileService { Future clearSizedThumbnailDiskCache() async { try { return platform.invokeMethod('clearSizedThumbnailDiskCache'); - } on PlatformException catch (e) { - await reportService.recordChannelError('clearSizedThumbnailDiskCache', e); + } on PlatformException catch (e, stack) { + await reportService.recordError(e, stack); } } @@ -295,8 +295,8 @@ class PlatformImageFileService implements ImageFileService { 'op': 'delete', 'entries': entries.map(_toPlatformEntryMap).toList(), }).map((event) => ImageOpEvent.fromMap(event)); - } on PlatformException catch (e) { - reportService.recordChannelError('delete', e); + } on PlatformException catch (e, stack) { + reportService.recordError(e, stack); return Stream.error(e); } } @@ -314,8 +314,8 @@ class PlatformImageFileService implements ImageFileService { 'copy': copy, 'destinationPath': destinationAlbum, }).map((event) => MoveOpEvent.fromMap(event)); - } on PlatformException catch (e) { - reportService.recordChannelError('move', e); + } on PlatformException catch (e, stack) { + reportService.recordError(e, stack); return Stream.error(e); } } @@ -333,8 +333,8 @@ class PlatformImageFileService implements ImageFileService { 'mimeType': mimeType, 'destinationPath': destinationAlbum, }).map((event) => ExportOpEvent.fromMap(event)); - } on PlatformException catch (e) { - reportService.recordChannelError('export', e); + } on PlatformException catch (e, stack) { + reportService.recordError(e, stack); return Stream.error(e); } } @@ -356,8 +356,8 @@ class PlatformImageFileService implements ImageFileService { 'destinationPath': destinationAlbum, }); if (result != null) return (result as Map).cast(); - } on PlatformException catch (e) { - await reportService.recordChannelError('captureFrame', e); + } on PlatformException catch (e, stack) { + await reportService.recordError(e, stack); } return {}; } @@ -371,8 +371,8 @@ class PlatformImageFileService implements ImageFileService { 'newName': newName, }); if (result != null) return (result as Map).cast(); - } on PlatformException catch (e) { - await reportService.recordChannelError('rename', e); + } on PlatformException catch (e, stack) { + await reportService.recordError(e, stack); } return {}; } @@ -386,8 +386,8 @@ class PlatformImageFileService implements ImageFileService { 'clockwise': clockwise, }); if (result != null) return (result as Map).cast(); - } on PlatformException catch (e) { - await reportService.recordChannelError('rotate', e); + } on PlatformException catch (e, stack) { + await reportService.recordError(e, stack); } return {}; } @@ -400,8 +400,8 @@ class PlatformImageFileService implements ImageFileService { 'entry': _toPlatformEntryMap(entry), }); if (result != null) return (result as Map).cast(); - } on PlatformException catch (e) { - await reportService.recordChannelError('flip', e); + } on PlatformException catch (e, stack) { + await reportService.recordError(e, stack); } return {}; } diff --git a/lib/services/media_store_service.dart b/lib/services/media_store_service.dart index 32f3acf4f..3363f1686 100644 --- a/lib/services/media_store_service.dart +++ b/lib/services/media_store_service.dart @@ -25,8 +25,8 @@ class PlatformMediaStoreService implements MediaStoreService { 'knownContentIds': knownContentIds, }); return (result as List).cast(); - } on PlatformException catch (e) { - await reportService.recordChannelError('checkObsoleteContentIds', e); + } on PlatformException catch (e, stack) { + await reportService.recordError(e, stack); } return []; } @@ -38,8 +38,8 @@ class PlatformMediaStoreService implements MediaStoreService { 'knownPathById': knownPathById, }); return (result as List).cast(); - } on PlatformException catch (e) { - await reportService.recordChannelError('checkObsoletePaths', e); + } on PlatformException catch (e, stack) { + await reportService.recordError(e, stack); } return []; } @@ -50,8 +50,8 @@ class PlatformMediaStoreService implements MediaStoreService { return _streamChannel.receiveBroadcastStream({ 'knownEntries': knownEntries, }).map((event) => AvesEntry.fromMap(event)); - } on PlatformException catch (e) { - reportService.recordChannelError('getEntries', e); + } on PlatformException catch (e, stack) { + reportService.recordError(e, stack); return Stream.error(e); } } diff --git a/lib/services/metadata_service.dart b/lib/services/metadata_service.dart index 258e34676..d3f329295 100644 --- a/lib/services/metadata_service.dart +++ b/lib/services/metadata_service.dart @@ -35,8 +35,8 @@ class PlatformMetadataService implements MetadataService { 'sizeBytes': entry.sizeBytes, }); if (result != null) return result as Map; - } on PlatformException catch (e) { - await reportService.recordChannelError('getAllMetadata', e); + } on PlatformException catch (e, stack) { + await reportService.recordError(e, stack); } return {}; } @@ -65,8 +65,8 @@ class PlatformMetadataService implements MetadataService { }) as Map; result['contentId'] = entry.contentId; return CatalogMetadata.fromMap(result); - } on PlatformException catch (e) { - await reportService.recordChannelError('getCatalogMetadata', e); + } on PlatformException catch (e, stack) { + await reportService.recordError(e, stack); } return null; } @@ -91,8 +91,8 @@ class PlatformMetadataService implements MetadataService { 'sizeBytes': entry.sizeBytes, }) as Map; return OverlayMetadata.fromMap(result); - } on PlatformException catch (e) { - await reportService.recordChannelError('getOverlayMetadata', e); + } on PlatformException catch (e, stack) { + await reportService.recordError(e, stack); } return null; } @@ -113,8 +113,8 @@ class PlatformMetadataService implements MetadataService { imagePage['rotationDegrees'] = entry.rotationDegrees; } return MultiPageInfo.fromPageMaps(entry, pageMaps); - } on PlatformException catch (e) { - await reportService.recordChannelError('getMultiPageInfo', e); + } on PlatformException catch (e, stack) { + await reportService.recordError(e, stack); } return null; } @@ -131,8 +131,8 @@ class PlatformMetadataService implements MetadataService { 'sizeBytes': entry.sizeBytes, }) as Map; return PanoramaInfo.fromMap(result); - } on PlatformException catch (e) { - await reportService.recordChannelError('PanoramaInfo', e); + } on PlatformException catch (e, stack) { + await reportService.recordError(e, stack); } return null; } @@ -145,8 +145,8 @@ class PlatformMetadataService implements MetadataService { 'uri': entry.uri, 'prop': prop, }); - } on PlatformException catch (e) { - await reportService.recordChannelError('getContentResolverProp', e); + } on PlatformException catch (e, stack) { + await reportService.recordError(e, stack); } return null; } diff --git a/lib/services/report_service.dart b/lib/services/report_service.dart index feab952a2..d642f8cb6 100644 --- a/lib/services/report_service.dart +++ b/lib/services/report_service.dart @@ -16,10 +16,6 @@ abstract class ReportService { Future recordError(dynamic exception, StackTrace? stack); Future recordFlutterError(FlutterErrorDetails flutterErrorDetails); - - Future recordChannelError(String method, PlatformException e) { - return recordError('$method failed with code=${e.code}, exception=${e.message}, details=${e.details}}', null); - } } class CrashlyticsReportService extends ReportService { diff --git a/lib/services/storage_service.dart b/lib/services/storage_service.dart index 53d460f5f..cba8baadf 100644 --- a/lib/services/storage_service.dart +++ b/lib/services/storage_service.dart @@ -47,8 +47,8 @@ class PlatformStorageService implements StorageService { try { final result = await platform.invokeMethod('getStorageVolumes'); return (result as List).cast().map((map) => StorageVolume.fromMap(map)).toSet(); - } on PlatformException catch (e) { - await reportService.recordChannelError('getStorageVolumes', e); + } on PlatformException catch (e, stack) { + await reportService.recordError(e, stack); } return {}; } @@ -60,8 +60,8 @@ class PlatformStorageService implements StorageService { 'path': volume.path, }); return result as int?; - } on PlatformException catch (e) { - await reportService.recordChannelError('getFreeSpace', e); + } on PlatformException catch (e, stack) { + await reportService.recordError(e, stack); } return null; } @@ -71,8 +71,8 @@ class PlatformStorageService implements StorageService { try { final result = await platform.invokeMethod('getGrantedDirectories'); return (result as List).cast(); - } on PlatformException catch (e) { - await reportService.recordChannelError('getGrantedDirectories', e); + } on PlatformException catch (e, stack) { + await reportService.recordError(e, stack); } return []; } @@ -83,8 +83,8 @@ class PlatformStorageService implements StorageService { await platform.invokeMethod('revokeDirectoryAccess', { 'path': path, }); - } on PlatformException catch (e) { - await reportService.recordChannelError('revokeDirectoryAccess', e); + } on PlatformException catch (e, stack) { + await reportService.recordError(e, stack); } return; } @@ -98,8 +98,8 @@ class PlatformStorageService implements StorageService { if (result != null) { return (result as List).cast().map(VolumeRelativeDirectory.fromMap).toSet(); } - } on PlatformException catch (e) { - await reportService.recordChannelError('getInaccessibleDirectories', e); + } on PlatformException catch (e, stack) { + await reportService.recordError(e, stack); } return {}; } @@ -111,8 +111,8 @@ class PlatformStorageService implements StorageService { if (result != null) { return (result as List).cast().map(VolumeRelativeDirectory.fromMap).toSet(); } - } on PlatformException catch (e) { - await reportService.recordChannelError('getRestrictedDirectories', e); + } on PlatformException catch (e, stack) { + await reportService.recordError(e, stack); } return {}; } @@ -134,8 +134,8 @@ class PlatformStorageService implements StorageService { cancelOnError: true, ); return completer.future; - } on PlatformException catch (e) { - await reportService.recordChannelError('requestVolumeAccess', e); + } on PlatformException catch (e, stack) { + await reportService.recordError(e, stack); } return false; } @@ -148,8 +148,8 @@ class PlatformStorageService implements StorageService { 'dirPaths': dirPaths.toList(), }); if (result != null) return result as int; - } on PlatformException catch (e) { - await reportService.recordChannelError('deleteEmptyDirectories', e); + } on PlatformException catch (e, stack) { + await reportService.recordError(e, stack); } return 0; } @@ -164,8 +164,8 @@ class PlatformStorageService implements StorageService { 'mimeType': mimeType, }); if (result != null) return Uri.tryParse(result); - } on PlatformException catch (e) { - await reportService.recordChannelError('scanFile', e); + } on PlatformException catch (e, stack) { + await reportService.recordError(e, stack); } return null; } @@ -188,8 +188,8 @@ class PlatformStorageService implements StorageService { cancelOnError: true, ); return completer.future; - } on PlatformException catch (e) { - await reportService.recordChannelError('createFile', e); + } on PlatformException catch (e, stack) { + await reportService.recordError(e, stack); } return false; } @@ -215,8 +215,8 @@ class PlatformStorageService implements StorageService { cancelOnError: true, ); return completer.future; - } on PlatformException catch (e) { - await reportService.recordChannelError('openFile', e); + } on PlatformException catch (e, stack) { + await reportService.recordError(e, stack); } return Uint8List(0); } @@ -236,8 +236,8 @@ class PlatformStorageService implements StorageService { cancelOnError: true, ); return completer.future; - } on PlatformException catch (e) { - await reportService.recordChannelError('selectDirectory', e); + } on PlatformException catch (e, stack) { + await reportService.recordError(e, stack); } return null; } diff --git a/lib/services/time_service.dart b/lib/services/time_service.dart index bc0ea606c..7f7cf2a4f 100644 --- a/lib/services/time_service.dart +++ b/lib/services/time_service.dart @@ -12,8 +12,8 @@ class PlatformTimeService implements TimeService { Future getDefaultTimeZone() async { try { return await platform.invokeMethod('getDefaultTimeZone'); - } on PlatformException catch (e) { - await reportService.recordChannelError('getDefaultTimeZone', e); + } on PlatformException catch (e, stack) { + await reportService.recordError(e, stack); } return null; } diff --git a/lib/services/viewer_service.dart b/lib/services/viewer_service.dart index 0a3bfa089..ec76a6bcc 100644 --- a/lib/services/viewer_service.dart +++ b/lib/services/viewer_service.dart @@ -9,8 +9,8 @@ class ViewerService { // returns nullable map with 'action' and possibly 'uri' 'mimeType' final result = await platform.invokeMethod('getIntentData'); if (result != null) return (result as Map).cast(); - } on PlatformException catch (e) { - await reportService.recordChannelError('getIntentData', e); + } on PlatformException catch (e, stack) { + await reportService.recordError(e, stack); } return {}; } @@ -20,8 +20,8 @@ class ViewerService { await platform.invokeMethod('pick', { 'uri': uri, }); - } on PlatformException catch (e) { - await reportService.recordChannelError('pick', e); + } on PlatformException catch (e, stack) { + await reportService.recordError(e, stack); } } } diff --git a/lib/services/window_service.dart b/lib/services/window_service.dart index cf204de4b..b325d264b 100644 --- a/lib/services/window_service.dart +++ b/lib/services/window_service.dart @@ -23,8 +23,8 @@ class PlatformWindowService implements WindowService { await platform.invokeMethod('keepScreenOn', { 'on': on, }); - } on PlatformException catch (e) { - await reportService.recordChannelError('keepScreenOn', e); + } on PlatformException catch (e, stack) { + await reportService.recordError(e, stack); } } @@ -33,8 +33,8 @@ class PlatformWindowService implements WindowService { try { final result = await platform.invokeMethod('isRotationLocked'); if (result != null) return result as bool; - } on PlatformException catch (e) { - await reportService.recordChannelError('isRotationLocked', e); + } on PlatformException catch (e, stack) { + await reportService.recordError(e, stack); } return false; } @@ -61,8 +61,8 @@ class PlatformWindowService implements WindowService { await platform.invokeMethod('requestOrientation', { 'orientation': orientationCode, }); - } on PlatformException catch (e) { - await reportService.recordChannelError('requestOrientation', e); + } on PlatformException catch (e, stack) { + await reportService.recordError(e, stack); } } @@ -71,8 +71,8 @@ class PlatformWindowService implements WindowService { try { final result = await platform.invokeMethod('canSetCutoutMode'); if (result != null) return result as bool; - } on PlatformException catch (e) { - await reportService.recordChannelError('canSetCutoutMode', e); + } on PlatformException catch (e, stack) { + await reportService.recordError(e, stack); } return false; } @@ -83,8 +83,8 @@ class PlatformWindowService implements WindowService { await platform.invokeMethod('setCutoutMode', { 'use': use, }); - } on PlatformException catch (e) { - await reportService.recordChannelError('setCutoutMode', e); + } on PlatformException catch (e, stack) { + await reportService.recordError(e, stack); } } }