It is better to use trycatch.HasCaught() to check raised exception. вторник, 31 июля 2012 г., 2:43:55 UTC+4 пользователь Anand Kumar написал: > > > I am trying to use v8 in my C++ application. I am stuck on the > helloworld itself! > > The helloworld at https://developers.google.com/v8/get_started works just > fine. Now I am trying to catch exceptions/error in the code. So I used > TryCatch trycatch;. > > int main(int argc, char *argv[]) { > HandleScope handle_scope; > Persistent<Context> context = Context::New(); > Context::Scope context_scope(context); > TryCatch trycatch; /* TO CATCH EXCETIONS/ERRORS */ > Handle<String> source = String::New("xyz();"); > Handle<Script> script = Script::Compile(source); > Handle<Value> result = script->Run(); > if (result.IsEmpty()) { > fprintf(stderr, "Exception: %s\n", > *String::AsciiValue(trycatch.Exception())); > return -1; > } > String::AsciiValue ascii(result); > printf("%s\n", *ascii); > context.Dispose(); > > return 0; > } > > The exceptions are caught fine but the program does not terminate > properly. It generates a segmentation fault. What am I doing wrong? > > Note: I am running 64-bit Ubuntu 11.10. I have compiled v8 source code using > make native. > >
-- v8-users mailing list [email protected] http://groups.google.com/group/v8-users
