Skip to content

options constructor accepts a context object - #19

Merged
DonutEspresso merged 2 commits into
masterfrom
context
Feb 4, 2016
Merged

DonutEspresso merged 2 commits into
masterfrom
context

Conversation

@DonutEspresso

Copy link
Copy Markdown
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
Copy Markdown
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

micahr commented Feb 4, 2016

Copy link
Copy Markdown
Contributor

Looks good to me, @DonutEspresso

@DonutEspresso

Copy link
Copy Markdown
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