本文整理汇总了C++中nan::TryCatch::SetCaptureMessage方法的典型用法代码示例。如果您正苦于以下问题:C++ TryCatch::SetCaptureMessage方法的具体用法?C++ TryCatch::SetCaptureMessage怎么用?C++ TryCatch::SetCaptureMessage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nan::TryCatch
的用法示例。
在下文中一共展示了TryCatch::SetCaptureMessage方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: EIO_AfterCallJs
void EIO_AfterCallJs(uv_work_t* req, int status) {
#else
void EIO_AfterCallJs(uv_work_t* req) {
#endif
DynamicProxyData* dynamicProxyData = static_cast<DynamicProxyData*>(req->data);
if(!dynamicProxyDataVerify(dynamicProxyData)) {
return;
}
dynamicProxyData->result = NULL;
JNIEnv* env;
int ret = dynamicProxyData->java->getJvm()->GetEnv((void**)&env, JNI_BEST_VERSION);
if (ret != JNI_OK) {
dynamicProxyData->throwableClass = "java/lang/IllegalStateException";
dynamicProxyData->throwableMessage = "Could not retrieve JNIEnv: jvm->GetEnv returned " + to_string<int>(ret);
dynamicProxyData->done = DYNAMIC_PROXY_JS_ERROR;
return;
}
Nan::HandleScope scope;
v8::Array* v8Args;
v8::Function* fn;
v8::Handle<v8::Value>* argv;
int argc;
int i;
v8::Local<v8::Value> v8Result;
jobject javaResult;
v8::Local<v8::Object> dynamicProxyDataFunctions = Nan::New(dynamicProxyData->functions);
v8::Local<v8::Value> fnObj = dynamicProxyDataFunctions->Get(Nan::New<v8::String>(dynamicProxyData->methodName.c_str()).ToLocalChecked());
if(fnObj->IsUndefined() || fnObj->IsNull()) {
dynamicProxyData->throwableClass = "java/lang/NoSuchMethodError";
dynamicProxyData->throwableMessage = "Could not find js function " + dynamicProxyData->methodName;
dynamicProxyData->done = DYNAMIC_PROXY_JS_ERROR;
return;
}
if(!fnObj->IsFunction()) {
dynamicProxyData->throwableClass = "java/lang/IllegalStateException";
dynamicProxyData->throwableMessage = dynamicProxyData->methodName + " is not a function";
dynamicProxyData->done = DYNAMIC_PROXY_JS_ERROR;
return;
}
fn = v8::Function::Cast(*fnObj);
if(dynamicProxyData->args) {
v8Args = v8::Array::Cast(*javaArrayToV8(dynamicProxyData->java, env, dynamicProxyData->args));
argc = v8Args->Length();
} else {
argc = 0;
}
argv = new v8::Handle<v8::Value>[argc];
for(i=0; i<argc; i++) {
argv[i] = v8Args->Get(i);
}
Nan::TryCatch tryCatch;
tryCatch.SetCaptureMessage(true);
v8Result = fn->Call(dynamicProxyDataFunctions, argc, argv);
delete[] argv;
if (tryCatch.HasCaught()) {
dynamicProxyData->throwableClass = "node/NodeJsException";
v8::String::Utf8Value message(tryCatch.Message()->Get());
dynamicProxyData->throwableMessage = std::string(*message);
tryCatch.Reset();
dynamicProxyData->done = DYNAMIC_PROXY_JS_ERROR;
return;
}
if(!dynamicProxyDataVerify(dynamicProxyData)) {
return;
}
javaResult = v8ToJava(env, v8Result);
if(javaResult == NULL) {
dynamicProxyData->result = NULL;
} else {
dynamicProxyData->result = env->NewGlobalRef(javaResult);
}
dynamicProxyData->done = true;
}