[quickjs-devel] Re: Error stack not available outside of catch block

  • From: Gus Caplan <me@xxxxxxxx>
  • To: quickjs-devel@xxxxxxxxxxxxx
  • Date: Fri, 6 Sep 2019 10:51:27 -0500

What most engines do is capture data about the stack when an error is
created, and then use either magical accessors (like v8) or actual
accessors (like spidermonkey) to lazily generate the final string.
Personally I would suggest using a real accessor (v8's method has caused
confusion over the years).

P.S., error.stack isn't actually specified anywhere, so there's not much to
go on in terms of intended behaviour.

On Fri, Sep 6, 2019, 01:30 Saúl Ibarra Corretgé <s@xxxxxxxxxx> wrote:

Hey there,

Not sure what the rule is, but I tested v8, chakra, spidermonkey and jsc
(https://github.com/GoogleChromeLabs/jsvu it's really awesome for this)
and they all set the error stack when the error object is created.
QuickJS OTOH, sets it as undefined until the error is thrown.

It's easy to workaround, but I think it breaks user expectations, as
creating a new error just to get the stack is commonly used to implement
console.trace, for example.


Cheers,

--
Saúl


Other related posts: