express-oauth-server
express-oauth-server copied to clipboard
Change handleError to throw or call next if not OAuthError
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
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.