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.

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

> Thanks for that! i've found that this odd scoping approach seems to work for 
> me:
>
>    Handle<Value> jsobj;
>    Handle<Value> ex;
>    Local<Object> jsobj;
>    {
>        TryCatch tryer;
>        jsobj = ... something which might throw ...
>        if( jsobj.IsEmpty() )
>        {
>            ex = tryer.Exception();
>        }
>    }
>    if( ! ex.IsEmpty() ) ThrowException(ex);
>
> if i don't do that (i.e., if "tryer" is not in a deeper scope) my
> exception messages aren't being passed up the chain properly. Weird.
>
>
> --
> ----- stephan beal
> http://wanderinghorse.net/home/stephan/
>
> >
>

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

Reply via email to