Bugfix: Change how errors are reported by ImageLoader. Emits as stream instead of re-throwing #937
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
✨ What kind of change does this PR introduce? (Bug fix, feature, docs update...)
This is a bug fix
If the
CachedNetworkImageProvider
gets some error when fetching an image url, then internally theImageLoader
will rethrow that error.This leads to the unwanted behavior that you get an uncaught exception.
And this for example then leads to faulty fatal errors being reported in Crashlytics.
🆕 What is the new behavior (if this is a feature change)?
Instead of throwing the error inside the
ImageLoader
, we are now emitting the error as a stream error into the current stream.This has the added benefit that this will not be an uncaught exception.
And all existing ErrorListeners, ErrorBuilders will still work.
💥 Does this PR introduce a breaking change?
No
🐛 Recommendations for testing
You can test this change with the existing example app.
If you run the example app for a mobile device and enabled the debugger to catch uncaught exceptions, then with this fix you will not get any uncaught exceptions. And before this fix, you would get uncaught exceptions for the
https://notAvalid.uri
and thenot a uri at all
.📝 Links to relevant issues/docs
N/A
🤔 Checklist before submitting
Screenshots
These screenshots come from VSCode running the previous version with
uncaught exceptions
turned on:And here is a screenshot coming from this version with
uncaught exceptions
turned on: