You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In my development testing I noticed that my try/catch catches a standard Error object that returns a string of the original error object as an Error.message instead of the original Error object. You were trying to preserve the call stack in your code. A problem is that JSON.stringify() actually has a string size limitation so large objects can truncate. Theoretically the Error.message cannot be reconverted back to the original error object thrown and the string conversions are slow. You may have snuck in a non-standard variable into the Error object as "originalError" to try to work around the truncation problem (or for convenience). Would not creating a new AsyncblockError object inherited from the Error class to officially store the original error object technically be what we need instead?
var errorParser = function(self, task) {
if(task.result && task.result[0] && task.firstArgIsError){
var err;
var firstArg = task.result[0];
if(firstArg instanceof Error){
//An error object was thrown, just use it
err = firstArg;
} else if(typeof firstArg === 'object'){
//Some sort of object was thrown, convert it into an error object to not lose stack info
err = new Error(JSON.stringify(firstArg));
Error.captureStackTrace(err, task.callback);
} else {
//Some primitive-ish thing was thrown, convert it into an error object to not lose stack info
err = new Error(firstArg);
Error.captureStackTrace(err, task.callback);
}
err.originalError = firstArg; <---------
task.error = err;
return err;
}
};
The text was updated successfully, but these errors were encountered:
In my development testing I noticed that my try/catch catches a standard Error object that returns a string of the original error object as an Error.message instead of the original Error object. You were trying to preserve the call stack in your code. A problem is that JSON.stringify() actually has a string size limitation so large objects can truncate. Theoretically the Error.message cannot be reconverted back to the original error object thrown and the string conversions are slow. You may have snuck in a non-standard variable into the Error object as "originalError" to try to work around the truncation problem (or for convenience). Would not creating a new AsyncblockError object inherited from the Error class to officially store the original error object technically be what we need instead?
The text was updated successfully, but these errors were encountered: