我正在尝试在我的 C++ 应用程序中使用 v8。我被困在 helloworld 本身!
https://developers.google.com/v8/get_started上的 helloworld工作得很好。现在我试图在代码中捕获异常/错误。所以我使用了 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;
}
异常被很好地捕获,但程序没有正确终止。它会产生分段错误。我究竟做错了什么?