-
Notifications
You must be signed in to change notification settings - Fork 2
Open
Labels
Description
Sometime it's useful to catch some known errors and convert them to erroz-errors. Unfortunately those errorz-erros have the stacktrace of erroz-creation. It might be helpful to add an option to pass an original error when creating an erroz-error instance to append the original error.
Something like:
var ParseError = erroz({
statusCode: 400,
status: "fail",
name: "ParseError",
code: "parse-error",
template "Could not parse %what"
});
try{
JSON.parse("xaz--");
}
catch(err) {
//pass original err as second argument (optional)
errozErr = new ParseError({ what: "ever" }, err);
console.log(errozErr.stack) //would equal err.stack
}Although it seems convenient it's also confusing as the stack is not pointing to the real "throw" . Maybe it's possible to merge the stacks or introduce a second originalStack attribute.