Michał, did you perhaps mean something like a 'cause' in Java or verror? https://docs.oracle.com/javase/7/docs/api/java/lang/Throwable.html#initCause(java.lang.Throwable) or https://github.com/joyent/node-verror
Then you would have: ``` try { catch Error('foo'); } catch (err) { throw Error('bar', err); } ``` On Mon, Aug 6, 2018 at 8:41 AM Jordan Harband <ljh...@gmail.com> wrote: > Stacks themselves aren't yet in the language, see > https://github.com/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`. > > On Mon, Aug 6, 2018 at 5:48 AM, Michał Wadas <michalwa...@gmail.com> > wrote: > >> Was there any proposal to introduce longer stack traces to language? >> >> Eg. >> ``` >> try { >> catch Error('foo'); >> } catch (err) { >> throw Error('bar'); // stack trace from caught error is lost >> } >> ``` >> >> >> >> >> _______________________________________________ >> es-discuss mailing list >> es-discuss@mozilla.org >> https://mail.mozilla.org/listinfo/es-discuss >> >> > _______________________________________________ > es-discuss mailing list > es-discuss@mozilla.org > https://mail.mozilla.org/listinfo/es-discuss >
_______________________________________________ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss