Skip to content

Handle error messages from services.#102

Open
mohsin wants to merge 1 commit intobeaulebens:trunkfrom
mohsin:develop
Open

Handle error messages from services.#102
mohsin wants to merge 1 commit intobeaulebens:trunkfrom
mohsin:develop

Conversation

@mohsin
Copy link
Copy Markdown

@mohsin mohsin commented Feb 5, 2022

This PR closes #101.

Details about the code in PR:

  • The 'removable_query_args' filter was added because Wordpress introduced a feature to remove certain parameters globally whenever present in URLs. Obviously, other services are going to return these parameters sometimes esp. error and message. So, this filter removes it for this plugin's admin UI to handle errors and show it to the user.
  • The keyring_handle_error_SERVICENAME filter allows services to handle their own error messages considering that errors are generally service/API-specific.
  • The action is set to services (in redirect_incoming_verify) to avoid it getting stuck in a redirect loop as that redirect handling code will keep getting triggered as long as error exists in the URL.
  • get_error_messages handles only 2 error codes since those were the ones I was able to reproduce (firstly in the issue I created and again during testing--the 1004 happens when user cancels, the 1006 one happens when either user cancels or the client secret is invalid ). I couldn't find any documentation that lists all the possible error codes (perhaps other APIs do and those could be added by other contributors).
  • On the same note as above, I found that Google does always sends error message as an underscored-slug text so I've humanized that and returned as a fallback error message that's better readable by a user.

* Displays any errors if the error parameter is set.
* Allows services to handle their own error messages via a keyring_handle_error_SERVICENAME filter.
@mohsin mohsin changed the title feat: Handle error messages from services. Handle error messages from services. Feb 5, 2022
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.

Error if I cancel during consent screen

1 participant