Skip to content

Expose typed error definitions for SDK errors #1336

@hugoecken

Description

@hugoecken

Checklist

  • I have looked into the Readme, Examples, and FAQ and have not found a suitable solution or answer.
  • I have looked into the API documentation and have not found a suitable solution or answer.
  • I have searched the issues and have not found a suitable solution or answer.
  • I have searched the Auth0 Community forums and have not found a suitable solution or answer.
  • I agree to the terms within the Auth0 Code of Conduct.

Describe the problem you'd like to have solved

I hope I've searched enough and I'm not requesting something that already exists ...

The SDK currently provides a good error handling structure:
when calling methods like authorize, clearSession, etc., the result can be checked via isError and error.

However, the error object only exposes a generic message, and developers have to parse the returned string to determine the actual error type (e.g. a0.session.user_cancelled, a0.network_error, etc.).
This makes error handling brittle and platform-dependent.

Describe the ideal solution

It would be very helpful if the SDK exposed typed error definitions or an exported Auth0Error enum/interface, for example:

import { Auth0ErrorType } from 'react-native-auth0';

try {
  await auth0.webAuth.clearSession();
} catch (e) {
  if (e.type === Auth0ErrorType.UserCancelled) {
    // handle user cancel cleanly
  }
}

Alternatives and current workarounds

No response

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature requestA feature has been asked for or suggested by the community

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions