Skip to content

Catch PlatformException on checkForUpdate method #107

Open
fleoparra wants to merge 6 commits intojonasbark:masterfrom
fleoparra:master
Open

Catch PlatformException on checkForUpdate method #107
fleoparra wants to merge 6 commits intojonasbark:masterfrom
fleoparra:master

Conversation

@fleoparra
Copy link
Copy Markdown

Android Studio and VS Code throws handled exceptions as uncaught when there is no an explicit Try Catch call in some cases. For example:

flutter/flutter#33427

fleoparra and others added 4 commits November 18, 2022 13:06
Android Studio and VS Code throws handled exceptions as uncaught when there is no an explicit Try Catch call in some cases. For example:

flutter/flutter#33427
@navaronbracke
Copy link
Copy Markdown

navaronbracke commented Aug 8, 2023

It is up to consumers of the plugin to handle a PlatformException properly. Just adding a catch here that merely rethrows the exception, does not add any value to it. (there are cases where plugins provide specific wrapper exceptions, but that is not very useful in this case)

The switch from jcenter to maven is a good catch, though.

For the VSCode thing, did you set Uncaught Exceptions on or off in the Breakpoints setting? IIRC that did cause some confusion over in Dart-Code a while back.

Screenshot 2023-08-08 at 21 14 10

@fleoparra
Copy link
Copy Markdown
Author

@navaronbracke. As you can see on flutter/flutter#33427, if you do not handle a PlatformException properly, there is a problem with try/catch on the editor debugging that code. Maybe for you is not important, but I think that can improve the quality of the library.

@navaronbracke
Copy link
Copy Markdown

@fleoparra According to dart-lang/sdk#37953 the underlying issue has been fixed.

But, if you were to add a catch block as you proposed, how would you surface the error to the end user?
Just wrapping the PlatformException into another Exception subclass does not add any value.
And catching the error and swallowing it, instead of rethrowing, leads to hard-to-understand behaviors.

I.e. "My plugin doesn't do anything if I do this, but why? Oh wait, it is catching an error but I cannot see what the error was since the plugin catches and consumes the error."

@fleoparra
Copy link
Copy Markdown
Author

fleoparra commented Sep 5, 2023

@navaronbracke Is weir. Using the latest version of flutter sdk, in my case, the error continues. There is some people with the problem #77.

Adding the catch block there is no problem surfacing the error because on catch code there is a throw e; line.

If someone has the error, can use:

  in_app_update:
    git:
      url: https://github.com/fleoparra/flutter_in_app_update.git
      ref: master

While there is another solution.

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

Successfully merging this pull request may close these issues.

3 participants