Throw with TypeError instead of Error
ibc opened this issue · 6 comments
Since this lib checks "types" it would make more sense to have check()
throw TypeError
instead of a generic `Error.
Or a new object that extends TypeError, so I can identity when it's an integration error or an internal error
Currently it throws VError
, which extends from Error
. You can check against that. I don't mind inheriting from TypeError instead, but there are quite a few kinds of internal bugs that manifest as TypeError. E.g. "Cannot read property 'foo' of null" is a TypeError. So TypeError is not very useful to distinguish validation from internal errors.
if this thown an error based on a lib class it's exactly what i need.
You are right, there is a deeper issue about extending Error. Could you check if this fixes the issue for you:
#27 ?
With v0.1.12, just released, you can import VError
and check for it using instanceof
.