Right, the correct formulation is "when control is passed *back* to JavaScript". :)
Thanks, -- Mads On Mon, Jan 17, 2011 at 9:06 AM, Ondřej Žára <[email protected]> wrote: > Hi Mads, > > thanks for a prompt response. Let me just add that "when control is > passed to JavaScript again" is not the most precise formulation: > > v8::TryCatch tc; > v8::ThrowException("..."); > v8::Script::New("1+1")->Run(); > if (tc.HasCaught()) { ... } > > Here the JS is indeed invoked after the exception has been thrown, but > nothing happens. Therefore, calling ThrowException has only sense when > executed from within a callback c++ function. > > > O. > > > > > 2011/1/17 Mads Sig Ager <[email protected]>: > > That observation is correct and it is the intended behavior. Through the > API > > you can throw JavaScript exceptions. If no JavaScript is running they > will > > have no effect. Exceptions scheduled through the api will be thrown when > > control is passed to JavaScript again. > > Cheers, -- Mads > > > > On Sat, Jan 15, 2011 at 9:43 PM, ondras <[email protected]> wrote: > >> > >> Hi, > >> > >> it looks like it is not possible to throw an exception from C++ when > there > >> is no JS code currently being executed. For instance: > >> > >> /* create context first etc... */ > >> v8::TryCatch tc; > >> v8::ThrowException("..."); > >> if (tc.HasCaught()) { ... } > >> > >> This external exception handler does not catch, even if I execute > >> arbitrary (non-throwing) javascript after calling the > v8::ThrowException(). > >> > >> 1) is my observation correct? > >> 2) is this behavior correct? > >> > >> > >> Thanks, > >> Ondrej > >> > >> -- > >> v8-users mailing list > >> [email protected] > >> http://groups.google.com/group/v8-users > > > > -- > > v8-users mailing list > > [email protected] > > http://groups.google.com/group/v8-users > > -- > v8-users mailing list > [email protected] > http://groups.google.com/group/v8-users > -- v8-users mailing list [email protected] http://groups.google.com/group/v8-users
