-
Notifications
You must be signed in to change notification settings - Fork 353
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
AuthenticationError not exported #700
Comments
Thanks for the report @someone1. Can you elaborate on this:
Are you saying you'd prefer a property on import { AuthenticationError } from '@auth0/auth0-spa-js'; How does that sound?
This is something we've already had additional feedback on and plan to address. It will probably come in the form of an additional readme in the repo that demonstrates the different error scenarios. Thanks for your additional feedback here! |
I think that'd definitely be a better way to import it, but this duck typing + casting approach is less than ideal. Even with the export I could not get the following code to work as I'd expect to be able to: try {
// ....
} catch(e) {
if (e instanceof AuthenticationError) {
// ...
}
} If the new export makes this method of error checking work then I think that'd be fine! |
🤔 we do reset the prototype according to this, so I might expect that to work. Let me look into it. Otherwise, I suppose we expected that you would simply check the try {
// ....
} catch(e) {
if (e.error === 'login_required') {
// ...
}
} It's just we don't have concrete error types for all the different types of error you might want to handle, so you'd probably have to discriminate on that at some stage anyway. |
Have you had any chance to look into this? Where possible, I'd rather detect known error types that are already being thrown and defined rather than fallback to the duck typing approach. |
Describe the problem you'd like to have solved
When Auth0 redirects back to the application with an error, we can't test for
AuthenticationError
Describe the ideal solution
add
AuthenticationError
toRedirectLoginResult
vs throwing it?Alternatives and current work-arounds
Additional context
There's also no real examples or guidance available of handling error responses from failed authentication requests - when would it be ok to ignore the error thrown here and try to authenticate again vs giving up. Are the errors here the same as the standard error responses?
I'm here since I ended up in an endless redirect loop!
The text was updated successfully, but these errors were encountered: