33// found in the LICENSE file.
44
55#include " shell/common/node_util.h"
6+ #include " base/logging.h"
67#include " shell/common/node_includes.h"
78#include " third_party/electron_node/src/node_native_module_env.h"
89
@@ -17,15 +18,22 @@ v8::MaybeLocal<v8::Value> CompileAndCall(
1718 std::vector<v8::Local<v8::Value>>* arguments,
1819 node::Environment* optional_env) {
1920 v8::Isolate* isolate = context->GetIsolate ();
21+ v8::TryCatch try_catch (isolate);
2022 v8::MaybeLocal<v8::Function> compiled =
2123 node::native_module::NativeModuleEnv::LookupAndCompile (
2224 context, id, parameters, optional_env);
2325 if (compiled.IsEmpty ()) {
2426 return v8::MaybeLocal<v8::Value>();
2527 }
2628 v8::Local<v8::Function> fn = compiled.ToLocalChecked ().As <v8::Function>();
27- return fn->Call (context, v8::Null (isolate), arguments->size (),
28- arguments->data ());
29+ v8::MaybeLocal<v8::Value> ret = fn->Call (
30+ context, v8::Null (isolate), arguments->size (), arguments->data ());
31+ // This will only be caught when something has gone terrible wrong as all
32+ // electron scripts are wrapped in a try {} catch {} in run-compiler.js
33+ if (try_catch.HasCaught ()) {
34+ LOG (ERROR) << " Failed to CompileAndCall electron script: " << id;
35+ }
36+ return ret;
2937}
3038
3139} // namespace util
0 commit comments