Skip to content

Commit

Permalink
🔊 Present exceptions in the image provider when debugging (#766)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexV525 authored May 16, 2022
1 parent 1a089bf commit 1f1861c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ that can be found in the LICENSE file. -->
Improvements:

- Protect cursors convert on Android. (#761)
- Present exceptions in the image provider when debugging. (#766)

Fixes:

Expand Down
1 change: 1 addition & 0 deletions lib/src/internal/constants.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ class PMConstants {
const PMConstants._();

static const String channelPrefix = 'com.fluttercandies/photo_manager';
static const String libraryName = 'photo_manager';

/// Keys for [MethodCall]s.
static const String mRequestPermissionExtend = 'requestPermissionExtend';
Expand Down
11 changes: 10 additions & 1 deletion lib/src/internal/image_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,16 @@ class AssetEntityImageProvider extends ImageProvider<AssetEntityImageProvider> {
throw StateError('The data of the entity is null: $entity');
}
return decode(data);
} catch (e) {
} catch (e, s) {
if (kDebugMode) {
FlutterError.presentError(
FlutterErrorDetails(
exception: e,
stack: s,
library: PMConstants.libraryName,
),
);
}
// Depending on where the exception was thrown, the image cache may not
// have had a chance to track the key in the cache at all.
// Schedule a microtask to give the cache a chance to add the key.
Expand Down

0 comments on commit 1f1861c

Please sign in to comment.