-
Notifications
You must be signed in to change notification settings - Fork 224
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
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