From: Robo Date: Sat, 24 Oct 2015 16:40:38 +0000 (+0530) Subject: nativemate: use maybe version of v8::Function::Call to avoid exceptions X-Git-Tag: v0.34.2~22^2 X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=70fe169b0f2c091c32ace2b5455e5023ad0bf143;p=electron.git nativemate: use maybe version of v8::Function::Call to avoid exceptions --- diff --git a/atom/common/native_mate_converters/callback.h b/atom/common/native_mate_converters/callback.h index 6e51cda7..68ea911f 100644 --- a/atom/common/native_mate_converters/callback.h +++ b/atom/common/native_mate_converters/callback.h @@ -70,10 +70,13 @@ struct V8FunctionInvoker { v8::Local holder = function->NewHandle(); v8::Local context = holder->CreationContext(); v8::Context::Scope context_scope(context); - ReturnType ret; + ReturnType ret = ReturnType(); std::vector> args = { ConvertToV8(isolate, raw)... }; - v8::Local val(holder->Call(holder, args.size(), &args.front())); - Converter::FromV8(isolate, val, &ret); + v8::Local result; + auto maybe_result = + holder->Call(context, holder, args.size(), &args.front()); + if (maybe_result.ToLocal(&result)) + Converter::FromV8(isolate, result, &ret); return ret; } };