Azard / egg-oauth2-server

:star2: OAuth2 server plugin for egg.js based on node-oauth2-server
MIT License
179 stars 45 forks source link

Allow to customize error handler #42

Closed sm2017 closed 5 years ago

sm2017 commented 5 years ago
Checklist
Description of change

As you always catch errors it is impossible to customizing errors for instance it is not possible to have a JSON response where we have UnauthorizedRequestError , or we cannot prevent ctx.app.emit('error', e, ctx); emitting , it is not good to log UnauthorizedRequestError or UnauthorizedClientError in production mode

codecov-io commented 5 years ago

Codecov Report

Merging #42 into master will decrease coverage by 0.68%. The diff coverage is 66.66%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #42      +/-   ##
==========================================
- Coverage      80%   79.31%   -0.69%     
==========================================
  Files           3        3              
  Lines          85       87       +2     
==========================================
+ Hits           68       69       +1     
- Misses         17       18       +1
Impacted Files Coverage Δ
config/config.default.js 100% <ø> (ø) :arrow_up:
lib/server.js 79.41% <66.66%> (-0.9%) :arrow_down:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 2d10b76...f79c99e. Read the comment docs.

Azard commented 5 years ago

@sm2017 Could you add a test case for this feature ?

sm2017 commented 5 years ago

Added Do you have a error handler I expect it throws when we have no middleware to handle error

Azard commented 5 years ago

@sm2017 Its better to handle the fail test case, or just remove the test case

sm2017 commented 5 years ago

@azard can you add test case? I expect 500 error, because it must throw unhanded exception but may be there is a middleware that catch it

Azard commented 5 years ago

https://github.com/Azard/egg-oauth2-server/pull/44