You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, I have a requirement where I want to catch only the No auth token errors on authentication failure.
Right now I have to check exactly the message property like this: err.message === 'No auth token'.
However, I'm afraid any future change in the error message might break my app.
This is a good point, either error classes (wich is against the offical passport documentation) or error messages should be put in an enum. Please add a PR (if you can directly to the rewrite)
Hi, I have a requirement where I want to catch only the
No auth token
errors on authentication failure.Right now I have to check exactly the
message
property like this:err.message === 'No auth token'
.However, I'm afraid any future change in the error message might break my app.
passport-jwt/lib/strategy.js
Line 96 in 96a6e55
So I request to define an error class for it like this:
and then throw that instead
This helps me to check the error using:
err instanceof NoAuthTokenError
, and any future change to the error message won't cause any breaking change.Lemme know if this sounds reasonable. I'll create a PR for the same then.
The text was updated successfully, but these errors were encountered: