herbsjs / herbs2rest

Create a REST API based on HerbsJS
MIT License
2 stars 13 forks source link

Handle Known Erros for better outputs #17

Closed dalssoft closed 2 years ago

dalssoft commented 3 years ago

Is your feature request related to a problem? Please describe. Improve Known Errors support for use case return.

Describe the solution you'd like Handle Err.xxxx, aka known erros, and return the proper HTTP status code.

maikvortx commented 3 years ago

Hi David, do you think defaultResolver should automatically interpret the error or should this be an option in the route settings?

dalssoft commented 3 years ago

If the use case return a Ok or a generic Err it should keep the current behavior. If it returns a Known Error, it should a proper HTTP status.

Given that I don't see the need for a extra option since this new behavior will not break the current clients.