Open chainlink opened 8 years ago
None of the middlewares exported by OAuth2Server
ever return an unknown error type. Unknown errors are always wrapped using ServerError
(#authenticate, #authorize, #token).
With #19 merged you can initialize the server like this:
new OAuthServer({
model: ...,
useErrorHandler: true
});
which tells express-oauth-server
to forward errors using next(err)
instead of sending a response by itself.
If the error encountered is not expected (ie. not an OAuth Library error) it should re throw the error (or at least pass it to next to be dealt with)
https://github.com/oauthjs/express-oauth-server/blob/master/index.js#L142
I propose checking if it's an instance of https://github.com/oauthjs/node-oauth2-server/blob/master/lib/errors/oauth-error.js
If you agree I can prepare a PR