Skip to content
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

Callback with invalid token error when resuming transaction instead of throwing it #29

Merged
merged 2 commits into from
Mar 20, 2017

Conversation

dafortune
Copy link
Contributor

Resume is async so it is better to callback with a documented exception when
the token is not valid.

…f throwing it

Resume is async so it is better to callback with a documented exception when
the token is not valid.
lib/index.js Outdated
try {
transactionTokenObject = jwtToken(transactionState.transactionToken);
} catch (e) {
throw new errors.InvalidToken('Invalid transaction token');
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the nested try-blocks are an unnecessary complexity; couldn't this be handled in the same catch as the rest? If there are more exceptions possible, just check for error name if it should be transformed?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately there is no error name to check, it is just an instance of error, the only thing I can check is the message

That is awful :'(

I made a PR to add an InvalidTokenError, but it's ok if you don't want to wait for that.
auth0/jwt-decode#48

@dafortune
Copy link
Contributor Author

dafortune commented Mar 17, 2017 via email

@dafortune dafortune merged commit bfe699f into auth0:master Mar 20, 2017
@dafortune dafortune deleted the add-invalid-token branch March 20, 2017 15:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants