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 <[email protected]> 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
> [email protected]
> https://mail.mozilla.org/listinfo/es-discuss
>
>
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to