Closed elstgav closed 11 months ago
Following up to:
it’s useful to have GenericError exported in addition to the other Error classes. This enables clients to quickly detect if they’re dealing with any kind of Auth0 Error:
GenericError
import { GenericError, useAuth0 } from '@auth0/auth0-react' const ErrorComponent = () => { const { error } = useAuth0() if (error instanceof GenericError) { console.log(error.error_description) } …
In auth0-react/src/index.tsx, export GenericError from auth0-spa-js:
auth0-react/src/index.tsx
auth0-spa-js
export { … + GenericError, … } from '@auth0/auth0-spa-js';
We can determine the GenericError by grabbing the prototype of any of the child errors:
import { AuthenticationError, useAuth0 } from '@auth0/auth0-react' const ErrorComponent = () => { const { error } = useAuth0() const GenericAuth0Error = Object.getPrototypeOf(AuthenticationError) if (error instanceof GenericError) { console.log(error.error_description) } …
All other errors were exported in:
Thanks for reaching out about this, i will make sure to add this, thanks!
Checklist
Describe the problem you'd like to have solved
Following up to:
it’s useful to have
GenericError
exported in addition to the other Error classes. This enables clients to quickly detect if they’re dealing with any kind of Auth0 Error:Describe the ideal solution
In
auth0-react/src/index.tsx
, exportGenericError
fromauth0-spa-js
:Alternatives and current workarounds
We can determine the GenericError by grabbing the prototype of any of the child errors:
Additional context
All other errors were exported in: