I want my C++ application to never crash because of a script. For now, I 
use v8::TryCatch to catch exceptions like calling undefined functions. But 
when the script isn't valid JavaScript, the whole application still crashed 
because of access violation. How can I prevent this? I may have to catch 
compilation errors somehow.

Here is my current C++ code to run a script.

        v8::Isolate *isolate = v8::Isolate::GetCurrent();
        v8::HandleScope scope(isolate);
 
        v8::Handle<v8::Script> script = 
v8::Script::Compile(v8::String::New(source));
                
        v8::TryCatch trycatch;
        v8::Local<v8::Value> result = script->Run();
        if(result.IsEmpty())
        {
                v8::Handle<v8::Value> exception = trycatch.Exception();
                v8::String::AsciiValue message(exception);
                std::cout << *message << std::endl;
        }
 
        v8::Persistent<v8::Value> handle = 
v8::Persistent<v8::Value>::New(isolate, result);


How can I prevent my application from crashing if the source code isn't 
valid JavaScript?

-- 
-- 
v8-users mailing list
[email protected]
http://groups.google.com/group/v8-users
--- 
You received this message because you are subscribed to the Google Groups 
"v8-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to