Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No way to catch error [Bug report] #658

Open
GeylanKalafMohe opened this issue Feb 1, 2024 · 5 comments
Open

No way to catch error [Bug report] #658

GeylanKalafMohe opened this issue Feb 1, 2024 · 5 comments

Comments

@GeylanKalafMohe
Copy link

GeylanKalafMohe commented Feb 1, 2024

Version

8.2.0

Platforms

Android, iOS

Device Model

iPhone 13 mini

flutter info

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.16.8, on macOS 13.6.4 22G513 darwin-x64, locale en-SA)
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.1)
[✓] Xcode - develop for iOS and macOS (Xcode 15.2)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2021.3)
[✓] VS Code (version 1.85.2)
[✓] Connected device (3 available)
[✓] Network resources

• No issues found!

How to reproduce?

How to handle error if one is thrown by the package?
It just throws error in console.. There should be a better way to handle error than throwing it. This issue still happens even after :
clearMemoryCacheIfFailed= true and defining failed widget by loadstatechanged

It still throws errors and there is no way to catch it

Exception caught by image resource service ════════════════════════════
The following StateError was thrown resolving an image codec:
Bad state: Failed to load https://tteemp.png.

Image provider: ExtendedNetworkImageProvider("https://temmp.png", scale: 1.0)
Image key: ExtendedNetworkImageProvider("https://tempp.png", scale: 1.0)

Logs

Exception caught by image resource service ════════════════════════════
The following StateError was thrown resolving an image codec:
Bad state: Failed to load https://tteemp.png.

Image provider: ExtendedNetworkImageProvider("https://temmp.png", scale: 1.0)
Image key: ExtendedNetworkImageProvider("https://tempp.png", scale: 1.0)

Example code (optional)

SizedBox(
            width: width,
            height: height,
            child: ClipRRect(
              borderRadius: decoration?.borderRadius ?? BorderRadius.zero,
              child: ExtendedImage.network(
                imageUrl!,
                fit: BoxFit.cover,
                cache: true,
                cacheMaxAge: const Duration(days: 15),
                clearMemoryCacheIfFailed: false,
                printError: false,
                loadStateChanged: (state) {
                  return switch (state.extendedImageLoadState) {
                    LoadState.loading => const AnimatedLoadingBubbles(
                        color: ColorManager.primaryIu,
                      ),
                    LoadState.failed => UIImagePlaceholder(
                        width: width,
                        height: height,
                        decoration: decoration,
                      ),
                    (_) => null,
                  };
                },
              ),
            ),
          );

Contact

reply to this issue

@zmtzawqlp
Copy link
Member

@zmtzawqlp
Copy link
Member

and for more , if the error is throw by http, then we can't do any thing for it

@GeylanKalafMohe
Copy link
Author

https://github.com/fluttercandies/extended_image_library/blob/d2e0a2299601248c55f58486dd90b4384f35f671/lib/src/network/network_image_io.dart#L265

you can set printError = false to ignore the error info to be print

I already set to false but it is still printing the error

@zmtzawqlp
Copy link
Member

https://github.com/fluttercandies/extended_image_library/blob/d2e0a2299601248c55f58486dd90b4384f35f671/lib/src/network/network_image_io.dart#L265
you can set printError = false to ignore the error info to be print

I already set to false but it is still printing the error

and for more , if the error is throw by http, then we can't do any thing for it

@GeylanKM
Copy link

https://github.com/fluttercandies/extended_image_library/blob/d2e0a2299601248c55f58486dd90b4384f35f671/lib/src/network/network_image_io.dart#L265
you can set printError = false to ignore the error info to be print

I already set to false but it is still printing the error

and for more , if the error is throw by http, then we can't do any thing for it

Please check this to fix your ImageProvider in order to catch errors

https://stackoverflow.com/questions/77165237/flutter-prevent-cachednetworkimageprovider-throwing-when-it-cannot-fetch-the-u

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants