-
Notifications
You must be signed in to change notification settings - Fork 61
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for custom error types? #15
Comments
👍 Joyent recommends using “the Error's name property to distinguish errors programmatically”. However, I can't see a way to use VError with custom error types – if everything has a name of |
Thanks for the pointer! I'll take a look at extend-error. There's a branch of VError that lets you set name and other properties here: https://github.com/davepacheco/node-verror/compare/props but I haven't had occasion to use it in an application so I haven't integrated it into master yet. |
My branch of VError may have what you are looking for It preserves the name property from the error cause rather than setting the name property to VError or WError. |
Maybe you should allow to extend VErrors by inheritance? Inheritance allows to use generic tests like As a side effect, |
P.S. Maybe it is allowed to inherit from |
@iliakan If you have successfully inherited VError can you provide an example . |
@iliakan I just checked the docs there is also a constructor function available so I can inherit easily. |
oh that was so long ago I can't even remember what the issue was about. There definitely was something. Withdrawing my question cause of lack of memories. |
@davepacheco Any updates on whether you'll merge in your branch? It'd be really nice to be able to use the new features. |
@yunong I haven't really had a chance to play with it much myself, so I haven't really validated the new design. Have you tried it? Or at least looked at the API? |
@naddison36 That is what I was looking for |
Another alternative for folks looking is restify-errors, we built it on top of VError (thanks Dave!) and made it relatively straightforward to create custom constructors and properties. |
I like the approach of defining custom type errors in this module https://github.com/jayyvis/extend-error , I think it would be great to add this functionality
The text was updated successfully, but these errors were encountered: