]> khamidou — GitHub mirrors - electron.git/commitdiff
nativemate: use maybe version of v8::Function::Call to avoid exceptions
authorRobo <hop2deep@gmail.com>
Sat, 24 Oct 2015 16:40:38 +0000 (22:10 +0530)
committerRobo <hop2deep@gmail.com>
Mon, 26 Oct 2015 05:29:40 +0000 (10:59 +0530)
atom/common/native_mate_converters/callback.h

index 6e51cda79c49db2bdb12165162a40ec2c4995864..68ea911fe143b7e102a528a05bbc83db1455e5ad 100644 (file)
@@ -70,10 +70,13 @@ struct V8FunctionInvoker<ReturnType(ArgTypes...)> {
     v8::Local<v8::Function> holder = function->NewHandle();
     v8::Local<v8::Context> context = holder->CreationContext();
     v8::Context::Scope context_scope(context);
-    ReturnType ret;
+    ReturnType ret = ReturnType();
     std::vector<v8::Local<v8::Value>> args = { ConvertToV8(isolate, raw)... };
-    v8::Local<v8::Value> val(holder->Call(holder, args.size(), &args.front()));
-    Converter<ReturnType>::FromV8(isolate, val, &ret);
+    v8::Local<v8::Value> result;
+    auto maybe_result =
+        holder->Call(context, holder, args.size(), &args.front());
+    if (maybe_result.ToLocal(&result))
+      Converter<ReturnType>::FromV8(isolate, result, &ret);
     return ret;
   }
 };