Skip to content

Conversation

@subhankarmaiti
Copy link
Contributor

@subhankarmaiti subhankarmaiti commented Dec 17, 2025

Completes the error code constants implementation from PR #1365

Usage

import { WebAuthError, WebAuthErrorCodes } from 'react-native-auth0';

try {
  await auth0.webAuth.authorize();
} catch (e) {
  if (e instanceof WebAuthError) {
    switch (e.type) {
      case WebAuthErrorCodes.USER_CANCELLED:
        // Handle cancellation
        break;
      case WebAuthErrorCodes.NETWORK_ERROR:
        // Handle network error
        break;
    }
  }
}

Related Issues

Resolves #1336

@subhankarmaiti subhankarmaiti requested a review from a team as a code owner December 17, 2025 11:57
Copy link

Copilot AI left a 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 completes the error code constants implementation for type-safe error handling in react-native-auth0. It introduces exported error code constants (WebAuthErrorCodes, CredentialsManagerErrorCodes, DPoPErrorCodes) that developers can use for better autocomplete support and type safety when handling authentication errors.

  • Exports error code constants for all three error types (WebAuth, CredentialsManager, DPoP)
  • Adds comprehensive JSDoc documentation with usage examples
  • Includes comprehensive test coverage for all error code constants
  • Updates README with recommended usage patterns
  • Provides working examples in the example app

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/index.ts Exports error code constants alongside their corresponding error classes
src/exports/enums.ts Re-exports error code constants for centralized enum access
src/core/models/index.ts Updates exports to include error code constants from each error model
src/core/models/WebAuthError.ts Adds comprehensive JSDoc and inline documentation for WebAuthErrorCodes constant
src/core/models/CredentialsManagerError.ts Adds comprehensive JSDoc and inline documentation for CredentialsManagerErrorCodes constant
src/core/models/DPoPError.ts Adds comprehensive JSDoc, inline documentation, and updates ERROR_CODE_MAP to reference DPoPErrorCodes constant
src/core/models/tests/ErrorCodes.spec.ts New comprehensive test suite validating all error code constants, uniqueness, and usage patterns
example/src/screens/hooks/Home.tsx Demonstrates WebAuthErrorCodes usage with type-safe switch statements for error handling
example/src/screens/hooks/CredentialsScreen.tsx Demonstrates CredentialsManagerErrorCodes usage with type-safe switch statements for error handling
README.md Adds recommended usage sections showing error code constants for both WebAuth and CredentialsManager errors

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@subhankarmaiti subhankarmaiti merged commit 46c5dab into master Dec 17, 2025
10 checks passed
@subhankarmaiti subhankarmaiti deleted the feat/export-error-code-constants branch December 17, 2025 13:22
@subhankarmaiti subhankarmaiti changed the title feat: complete error code constants implementation and add example usage feat: complete error code constants implementation Dec 17, 2025
@subhankarmaiti subhankarmaiti mentioned this pull request Dec 18, 2025
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.

Expose typed error definitions for SDK errors

4 participants