Error caused by other error
Stacks themselves aren't yet in the language, see tc39/proposal-error-stacks.
As for "the stack trace from the caught error", it's lost because you let
err
go out of scope - if you want to preserve err.stack
, you have to do
so (with throw err
, or by saving the information somewhere, like on your
newly created error). Also, stacks are generated at the time the error
object is instantiated, not at the place you throw
.
Michał, did you perhaps mean something like a 'cause' in Java or verror? docs.oracle.com/javase/7/docs/api/java/lang/Throwable.html#initCause(java.lang.Throwable) or joyent/node-verror
Then you would have:
try {
catch Error('foo');
} catch (err) {
throw Error('bar', err);
}
don't knwo where yuo're having problems... in node stackoverflow.com/questions/7697038/more-than-10-lines-in-a-node-js-stack-error which is
Error.stackTraceLimit = Infinity;
which maywork in chrome too
Was there any proposal to introduce longer stack traces to language?
Eg.