Skip to content
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

options constructor accepts a context object #19

Merged
merged 2 commits into from
Feb 4, 2016
Merged

Conversation

DonutEspresso
Copy link
Member

I'm finding I frequently want to add contextual properties to an object I'm creating to store some context about what might have caused that error. i.e., if an http request failed, I might want to put the url on the error object.

Since we already have the options constructor, this seemed like a good place to put it. All arbitrary context properties are stored on the context property instead of directly on the error itself.

Suggestions/feedback @yunong @micahr?

@DonutEspresso
Copy link
Member Author

BTW, the intent is to use this in conjunction with bunyan. Sometimes I want to propagate an error up two or three callbacks before logging it out - but I've lost the context by then. This allows me to keep that context tied with the error.

The context property is ignored when calling toJSON() or toString() in the event it is sent out over the wire.

@micahr
Copy link
Member

micahr commented Feb 4, 2016

Looks good to me, @DonutEspresso

@DonutEspresso
Copy link
Member Author

Looks like we're all on board - may have to come up with some custom serializers for bunyan to support dumping of context.

DonutEspresso added a commit that referenced this pull request Feb 4, 2016
options constructor accepts a context object
@DonutEspresso DonutEspresso merged commit fd9d25e into master Feb 4, 2016
@DonutEspresso DonutEspresso deleted the context branch February 4, 2016 21:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants