nativemate: use maybe version of v8::Function::Call to avoid exceptions
This commit is contained in:
parent
2effe6eff5
commit
70fe169b0f
1 changed files with 6 additions and 3 deletions
|
@ -70,10 +70,13 @@ struct V8FunctionInvoker<ReturnType(ArgTypes...)> {
|
||||||
v8::Local<v8::Function> holder = function->NewHandle();
|
v8::Local<v8::Function> holder = function->NewHandle();
|
||||||
v8::Local<v8::Context> context = holder->CreationContext();
|
v8::Local<v8::Context> context = holder->CreationContext();
|
||||||
v8::Context::Scope context_scope(context);
|
v8::Context::Scope context_scope(context);
|
||||||
ReturnType ret;
|
ReturnType ret = ReturnType();
|
||||||
std::vector<v8::Local<v8::Value>> args = { ConvertToV8(isolate, raw)... };
|
std::vector<v8::Local<v8::Value>> args = { ConvertToV8(isolate, raw)... };
|
||||||
v8::Local<v8::Value> val(holder->Call(holder, args.size(), &args.front()));
|
v8::Local<v8::Value> result;
|
||||||
Converter<ReturnType>::FromV8(isolate, val, &ret);
|
auto maybe_result =
|
||||||
|
holder->Call(context, holder, args.size(), &args.front());
|
||||||
|
if (maybe_result.ToLocal(&result))
|
||||||
|
Converter<ReturnType>::FromV8(isolate, result, &ret);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue