JS-DevTools / ono

Wrap errors without losing the original message, stack trace, or properties
https://jstools.dev/ono/
MIT License
106 stars 11 forks source link

Add HTTP Errors #2

Closed danieljoppi closed 5 years ago

danieljoppi commented 7 years ago

some like this

const ono = require('ono');

ono.badRequet(); // => ono( {status: 400, message: 'Bad Request'})
ono.unauthorized(); // => ono({status: 401, message: 'Unauthorized'})
ono.forbidden(); // => ono({status: 403, message: 'Forbidden'})
ono.notFound(); // => ono({status: 404, message: 'Not Found'})
JamesMessinger commented 7 years ago

I like this idea, but I think it should be a separate npm package (e.g. ono-http) rather than part of the main ono package.

JamesMessinger commented 5 years ago

We just released Ono v5.0, which allows you to define your own custom ono methods. So it's now super easy to implement HTTP errors like the ones described above. More details here