-
Notifications
You must be signed in to change notification settings - Fork 228
feat: unify and improve error handling across platforms #1261
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
Conversation
…pdate error codes
…into SDK-5700-platform-agnostic-error
…k implementations
…er and update error codes" This reverts commit c7c427c.
…o improve clarity
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR unifies error handling across Native (iOS/Android) and Web platforms by introducing platform-agnostic error classes and standardized error codes. The changes address developer experience issues by eliminating the need for platform-specific error handling code.
- Introduces
WebAuthError
class with typed error codes for consistent error identification across platforms - Adds platform-agnostic
CredentialsManagerError
mapping for web platform compatibility - Updates native SDK dependencies to leverage improved error reporting capabilities
Reviewed Changes
Copilot reviewed 13 out of 14 changed files in this pull request and generated 2 comments.
Show a summary per file
File | Description |
---|---|
src/core/models/WebAuthError.ts |
New error class that maps platform-specific codes to unified error types |
src/core/models/CredentialsManagerError.ts |
Extended error mappings to include web platform error codes |
src/platforms/web/adapters/WebWebAuthProvider.ts |
Updated to throw WebAuthError instead of AuthError for consistent handling |
src/platforms/web/adapters/WebCredentialsManager.ts |
Updated to throw CredentialsManagerError for platform consistency |
src/platforms/native/adapters/NativeWebAuthProvider.ts |
Wrapped native errors in WebAuthError for unified error handling |
android/build.gradle |
Updated auth0-android dependency from 3.2.1 to 3.8.0 |
A0Auth0.podspec |
Updated Auth0.swift dependency from 2.10 to 2.13 |
README.md |
Added comprehensive error handling documentation with before/after examples |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@subhankarmaiti Could you add more test cases to validate these changes for different platform specific error scenarios ?
…and WebWebAuthProvider
… in NativeCredentialsManager and NativeWebAuthProvider
| `INVALID_CREDENTIALS` | `INVALID_CREDENTIALS` | | | | ||
| `NO_CREDENTIALS` | `NO_CREDENTIALS` | `noCredentials` | `login_required` | | ||
| `NO_REFRESH_TOKEN` | `NO_REFRESH_TOKEN` | `noRefreshToken` | | ||
| `RENEW_FAILED` | `RENEW_FAILED` | `renewFailed` | `missing_refresh_token`, `invalid_grant`,`consent_required` | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
invalid_grant
,consent_required
Have we thought about how to handle when web returns these two errors when logging in the first time and not renewing ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pmathew92 This error won’t occur during login. It comes from the getTokenSilently
call, which is why we map it as RENEW_FAILED.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@subhankarmaiti Ok. But I would still suggest to cross check before merging the same
@subhankarmaiti Could we add few more test cases where all 3 platforms send different error types |
…ager and webautherror
* master: feat: add Claude Code PR Review workflow for enhanced pull request an… (#1317) feat: enhance Auth0Provider with platform-specific initialization and error handling (#1313) feat(web): Simplify Setup, Add Session Check & Fix Missing Refresh Token (#1303) Fix clearSession operation order to prevent premature user state clearing (#1309) Release v5.0.0-beta.6 (#1306) fix: concurrent credential storage errors by preventing unnecessary state updates (#1302) chore(deps): bump actions/checkout from 4 to 5 (#1272) chore(deps): bump actions/download-artifact from 4 to 5 (#1294) chore(deps): bump codecov/codecov-action from 5.5.0 to 5.5.1 (#1296) fix(docs): added back the docs folder (#1291) Release v5.0.0-beta.5 (#1290) fix(docs): organize exports into namespaces for better typedocs (#1269) fix: add missing clearSession native options (#1289) fix(android): add pathPrefix to Android manifest for proper App Links functionality (#1288) feat: add organization parameter support to resetPassword API (#1286) feat(auth): add `saveCredentials` method to `useAuth0` hook (#1285) feat: unify and improve error handling across platforms (#1261) chore(deps): bump codecov/codecov-action from 5.4.3 to 5.5.0 (#1279)
This PR unifies error handling across Native (iOS/Android) and Web platforms, providing a consistent, platform-agnostic model that addresses the developer experience issues raised in #923.
Key Changes:
CredentialsManagerError
and the newWebAuthError
now map platform-specific and web error codes to a single, consistent set of codes.WebAuthError
: Introduces aWebAuthError
class with a.type
property (e.g.,'USER_CANCELLED'
) for easy, reliable error identification, eliminating the need forPlatform.OS
checks.auth0-android
to3.8.0
andAuth0.swift
to2.13.0
to leverage their latest error reporting capabilities.README.md
is updated with new error tables and "Before/After" code examples to guide developers on the new, simplified approach.Fixes: #923, #1260