customize how errors are done?
Raynos opened this issue · comments
I want to depend on on raw-body
but handle errors slightly differently.
Currently I handle errors like ( https://github.com/Raynos/body/blob/master/index.js#L5 )
The difference is that I have a statusCode
property instead of status
and each one of my errors has a type
field.
One option is for me to just create new errors or wrap the errors raw-body
passes up. Not sure how else to deal with differences.
adding statusCode
isn't a big deal. type
isn't either. i prefer not to add options for errors though, things will get out of hand.
okay i added statusCode
and type
. can you make sure the errors are to your liking before i publish?
@jonathanong type is fine.
Btw I use err.type
in error checks if (err.type === "entity.too.large")
because checking the message is dangerous. Modules authors tend to change the message too much or the message is dynamic and would require a regexp to check.
The type
contract is only valuable if the type
is never changed / refactored.
yeah, i don't check err.message
. in my own app i do err.key
instead of err.type
because type
doesn't imply specificity (type of car, type of person) where as key
or code
does.
i don't care about HTTP errors though since most of the time they are developer errors.
@jonathanong you may want to add tests that the 'type' key is there.
I've had issues with node being weird in the passed and me having to use defineProperty()
( https://github.com/Raynos/error/blob/master/typed.js#L16 )
yay! 1.1.0