On Mon, Mar 16, 2009 at 1:15 AM, Christian Plesner Hansen
<[email protected]> wrote:
> This code is not safe.  In the documentation for TryCatch::Exception
> it says "The returned handle is valid until this TryCatch block has
> been destroyed.", so 'ex' becomes invalid as soon as the scope
> containing the TryCatch ends.

But that also implies that it becomes invalid once the function
returns, because TryCatch is destroyed there, too. ? Ergo, i assumed
that i could avoid it going out of scope by copying the handle.

> If you're rethrowing the exception anyway is there a reason to catch
> it in the first place?

i started experimenting when some of my exceptions were coming back to
the shell with empty message text. i found that i could work around
that by copying the exception and re-throwing it. It was just a
workaround.

In hindsight, i think my call chains in those cases were going
JS->C++->JS->C++ (and then back):

var x = create_thingie(); // as opposed to: new Thingy()

that calls an InvocationCallback which in turn calls NewInstance() on
a ctor function we've cached away in the function data (the ctor for
Thingy). That NewInstanceCall() essentially takes me back into JS
space for the constructor call (which, in turn, triggers another
internal ctor-style InvocationCallback for Thingy's construction). The
constructor throws (invalid arguments or whatever), the exception gets
back to my InvocationCallback, and that's where my problem happens.
When i pass the exception out of there, the shell is saying "<string
conversion failed>", which means that the exception string was empty.
So i started experimenting and came up with that dubious workaround
(now any throws from the ctor get passed back up the chain properly
(or at least it "works for me")).

Anyway...

-- 
----- stephan beal
http://wanderinghorse.net/home/stephan/

--~--~---------~--~----~------------~-------~--~----~
v8-users mailing list
[email protected]
http://groups.google.com/group/v8-users
-~----------~----~----~----~------~----~------~--~---

Reply via email to