-
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
better support for extra properties on Errors #10
Comments
+1 |
Would you merge a pull request which adds this behavior? I find it very useful to merge errors rather than push them onto an error stack. |
@cappslock Check out #15. I have a branch that supports this but I haven't played with it much in anything real. Let me know what you think. |
👍 |
@davepacheco, @yunong and I recently added support for contextual properties in restify-errors. For now, we opted to maintain all that context in its own bucket and additionally added support for a custom bunyan serializer that iterates through those context properties. The scope for this feature was mostly to add additional context, since overriding name and other "native" error properties are done at constructor creation time. We'd love to see something like this supported natively in verror and bunyan. We're not particularly opinionated about the how, but do think this is a pretty valuable use case. I saw that you had a branch that already does some of this - any thoughts on how we can help get this feature integrated? |
@DonutEspresso yes, it's long past time to merge this. Given how widely we use this library, it's really important that the change be backwards-compatible, and supportable indefinitely as well. That's the main reason I haven't merged it -- I haven't prioritized trying it in some projects to make sure it does what we'd hope from such an interface, and I haven't heard that anybody else has either. It's probably time to update that branch and try it out. |
FWIW: I've rebased the changes I had before, and decided to make a few interfaces changes. I'm mostly through putting together a complete description of the new interface, and it shouldn't take all that long to update the code and tests to match and build some useful examples. I hope to have something for this soon, and I'll be interested in feedback. Thanks for the patience. |
This still needs some cleanup and improved examples, but here's where I am right now: I'd suggest checking out the new README.md. Here are the non-trivial design choices I went with:
I'd be interested in feedback on this (CC @jclulow). The full diff is here, but includes a ton of noise because as part of this change I'm bringing a bunch of other stuff up to date: Unrelated changes I made as part of this:
|
@DonutEspresso, @yunong, or anyone else: have you had a chance to review those changes? |
Unfortunately I haven't had a chance yet to check it out - been super heads down the last few weeks. I'll try to take a look sometime next week. Thanks for the hard work! |
I understand -- no problem at all! |
I've been trying this on a new project of my own, and I've found a small problem with the interface: it uses a new method called info(), but in general, when you've got an Error object, you don't know if you can call info() because you don't know if it's a VError or not. As a result, I'm leaning towards replacing the info() method with a class function (rather than an instance method) called I'm also leaning towards implementing #11 along with this because as I write new code to work with cause chains reasonably, I find I need that functionality as well. I would similarly implement that using a VError.findCause() method rather than adding a method to VError instances. Thoughts? |
I've updated my branch to include the changes in my previous comment. |
I started work on a new module that is pretty stand alone, which gives me the perfect opportunity to try out the new changes. Is |
That would be great, and yes, that's the right branch. Hopefully the documentation is much better now! There's also a detailed design at https://github.com/joyent/rfd/tree/master/rfd/0041. |
I'm just about ready to land this. Any last feedback would be great. |
Sorry for delay - been using this for a bit now and have found it great for modules. Typed errors work well at the application layer, but quickly become unruly since instanceof checks can easily fail as different context(s) are built up. No complaints here at the moment! I do think native Bunyan integration would be excellent. I'm happy to write my own serializer as we did for restify-errors, but it would be pretty rad if bunyan had this baked in. Do you know if there are any plans to make that happen? |
It would be nice to support putting more properties on Errors. That means:
CC @jclulow @tjfontaine
The text was updated successfully, but these errors were encountered: