>
> > void test() {
> >
> > v8::HandleScope hs;
> >
> > v8::ThrowException(v8::String::New("!"));
>
> There might (er, will) be those here who disagree with me on this point,
> but my recommendation is to get rid of the HandleScope. In 9 out of 10 cases
> they cause segfaults for me.
>

Independently on what your experience with Handle Scopes is, my test behaves
the same if I remove it.

> v8::TryCatch tc;
>
> test();
> if (tc.HasCaught()) {

HasCaught() is new to me. The v8 docs say we should do:
>
> Handle<Value> x = myfunc();
> if( x.IsEmpty() ) {
> ... this theoretically means an exception was thrown, though an empty
> handle can be created w/o throwing...
> }
>
> i don't have access to the API docs at the moment, but if i'm not mistaken,
> that is the documented approach
>


HasCaught() is documented and heavily used in unit tests. It surely is the
preferred way of checking whether an exception has been thrown.

However, I believe that I found the reason no exception was catched: one
_must_ return to JS (by executing script->Run()) before checking
trycatch->HasCaught(). Until a JS execution commences, no exception thrown
from the C++ side is actually caught.


Ondrej




>
> >
>

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

Reply via email to