Skip to content
This repository has been archived by the owner on Feb 22, 2023. It is now read-only.

[google_sign_in_web] Ensure web plugin throws PlatformExceptions #2943

Merged
merged 12 commits into from Sep 14, 2020

Conversation

ditman
Copy link
Member

@ditman ditman commented Aug 19, 2020

Description

The web version of the plugin wasn't very good at throwing exceptions:

  • Errors on init() weren't being unpacked correctly in release or profile mode, because of a missing JS-interop class. This prevented the code from throwing a proper PlatformException.
  • Errors on signIn() were being rethrown as JS Objects, instead of wrapping them correctly in a PlatformException.

This PR ensures that the methods above throw the appropriate exception every time, regardless of the environment (dev vs release).

This PR also aligns the fields of the PlatformException with those coming from the mobile side, so:

  • PlatformException.code is now what the Google Sign In SDK calls "error".
  • .message is now what the Google Sign In SDK calls "details" (when available).
  • .details is 'google_sign_in'

See multiple "Error Codes" here: https://developers.google.com/identity/sign-in/web/reference#error_codes

Finally, the tests on the package have been migrated to run with flutter drive + chromedriver instead of other options.

Related Issues

Checklist

Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes ([x]). This will ensure a smooth and quick review process.

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • My PR includes unit or integration tests for all changed/updated/fixed behaviors (See Contributor Guide).
  • All existing and new tests are passing.
  • I updated/added relevant documentation (doc comments with ///).
  • The analyzer (flutter analyze) does not report any problems on my PR.
  • I read and followed the Flutter Style Guide.
  • The title of the PR starts with the name of the plugin surrounded by square brackets, e.g. [shared_preferences]
  • I updated pubspec.yaml with an appropriate new version according to the pub versioning philosophy.
  • I updated CHANGELOG.md to add a description of the change.
  • I signed the CLA.
  • I am willing to follow-up on review comments in a timely manner.

Breaking Change

Does your PR require plugin users to manually update their apps to accommodate your change?

  • No, this is not a breaking change.

Copy link
Contributor

@cyanglaz cyanglaz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we test this?

@ditman
Copy link
Member Author

ditman commented Aug 19, 2020

Can we test this?

@cyanglaz I need to migrate the tests to e2e first, but I can shave that yak for this PR, yes.

(Main goal of publishing this early was for people affected by the bugs above to try this branch and see if their apps behave better)

@ditman ditman changed the title [google_sign_in_web] Ensure web plugin throws PlatformExceptions [google_sign_in_web] [WIP] Ensure web plugin throws PlatformExceptions Aug 19, 2020
@ditman ditman force-pushed the google-sign-in-swallowed-errors branch 2 times, most recently from bb6b758 to 3ab3c4c Compare August 24, 2020 23:53
@ditman
Copy link
Member Author

ditman commented Aug 25, 2020

@cyanglaz I've migrated the tests to run as flutter drive (instead of flutter test --platform chrome), and added a few tests for the new behavior. PTAL!

@ditman ditman requested a review from cyanglaz August 25, 2020 00:00
@ditman ditman changed the title [google_sign_in_web] [WIP] Ensure web plugin throws PlatformExceptions [google_sign_in_web] Ensure web plugin throws PlatformExceptions Aug 25, 2020
@ditman ditman force-pushed the google-sign-in-swallowed-errors branch from ef919a0 to 80663d0 Compare September 11, 2020 19:17
Copy link
Contributor

@cyanglaz cyanglaz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ditman ditman merged commit 56410f5 into flutter:master Sep 14, 2020
@ditman ditman deleted the google-sign-in-swallowed-errors branch September 14, 2020 19:38
@ditman
Copy link
Member Author

ditman commented Sep 14, 2020

Published v0.9.2.

danielroek pushed a commit to Baseflow/flutter-plugins that referenced this pull request Sep 18, 2020
…#2943)

Instead of throwing JS objects, or attempting to access undefined properties.

This change also migrates tests to the `integration_test` package.
jorgefspereira pushed a commit to jorgefspereira/plugins_flutter that referenced this pull request Oct 10, 2020
…#2943)

Instead of throwing JS objects, or attempting to access undefined properties.

This change also migrates tests to the `integration_test` package.
FlutterSu pushed a commit to FlutterSu/flutter-plugins that referenced this pull request Nov 20, 2020
…#2943)

Instead of throwing JS objects, or attempting to access undefined properties.

This change also migrates tests to the `integration_test` package.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
3 participants