This repository was archived by the owner on Jan 21, 2024. It is now read-only.

Description
Consider this scenario:
function someOperation() {
function someOperationFailure(e) {
//handle failure
}
$.ajax({ ... })
.done(function(resp) {
if (!resp.userToken) {
someOperationFailure(new Error('no userToken!' );
}
}
someOperationFailure gets a message that there's no userToken, but what actually was the response?
We could JSON.stringify it into the message, or, I could make a new class that inherits from Error that accepts multiple arguments, and acts intelligently, like adding the data to the error object, and/or maybe adding it onto the e.message.
May or may not be a part of TraceKit, just trying to brainstorm and get feedback.
It would also probably be pretty useful for TraceKit to offer a vanilla normalize function, doing something like var e = TraceKit.normalize(new Error('message')) and then you could just add your data to this normalized error like: e.response = resp in the above scenario.