@@ -1511,24 +1511,22 @@ void ContextifyContext::CompileFunction(
15111511 }
15121512
15131513 TryCatchScope try_catch (env);
1514- Local<Object> result = CompileFunctionAndCacheResult (env,
1515- parsing_context,
1516- &source,
1517- params,
1518- context_extensions,
1519- options,
1520- produce_cached_data,
1521- id_symbol,
1522- try_catch);
1523-
1524- if (try_catch.HasCaught () && !try_catch.HasTerminated ()) {
1514+ MaybeLocal<Object> maybe_result =
1515+ CompileFunctionAndCacheResult (env,
1516+ parsing_context,
1517+ &source,
1518+ params,
1519+ context_extensions,
1520+ options,
1521+ produce_cached_data,
1522+ id_symbol,
1523+ try_catch);
1524+ Local<Object> result;
1525+ if (!maybe_result.ToLocal (&result)) {
1526+ CHECK (try_catch.HasCaught ());
15251527 try_catch.ReThrow ();
15261528 return ;
15271529 }
1528-
1529- if (result.IsEmpty ()) {
1530- return ;
1531- }
15321530 args.GetReturnValue ().Set (result);
15331531}
15341532
@@ -1544,7 +1542,7 @@ static LocalVector<String> GetCJSParameters(IsolateData* data) {
15441542 return result;
15451543}
15461544
1547- Local <Object> ContextifyContext::CompileFunctionAndCacheResult (
1545+ MaybeLocal <Object> ContextifyContext::CompileFunctionAndCacheResult (
15481546 Environment* env,
15491547 Local<Context> parsing_context,
15501548 ScriptCompiler::Source* source,
@@ -1566,28 +1564,29 @@ Local<Object> ContextifyContext::CompileFunctionAndCacheResult(
15661564
15671565 Local<Function> fn;
15681566 if (!maybe_fn.ToLocal (&fn)) {
1569- if (try_catch.HasCaught () && !try_catch.HasTerminated ()) {
1567+ CHECK (try_catch.HasCaught ());
1568+ if (!try_catch.HasTerminated ()) {
15701569 errors::DecorateErrorStack (env, try_catch);
1571- return Object::New (env->isolate ());
15721570 }
1571+ return {};
15731572 }
15741573
15751574 Local<Context> context = env->context ();
15761575 if (fn->SetPrivate (context, env->host_defined_option_symbol (), id_symbol)
15771576 .IsNothing ()) {
1578- return Object::New (env-> isolate ()) ;
1577+ return {} ;
15791578 }
15801579
15811580 Isolate* isolate = env->isolate ();
15821581 Local<Object> result = Object::New (isolate);
15831582 if (result->Set (parsing_context, env->function_string (), fn).IsNothing ())
1584- return Object::New (env-> isolate ()) ;
1583+ return {} ;
15851584 if (result
15861585 ->Set (parsing_context,
15871586 env->source_map_url_string (),
15881587 fn->GetScriptOrigin ().SourceMapUrl ())
15891588 .IsNothing ())
1590- return Object::New (env-> isolate ()) ;
1589+ return {} ;
15911590
15921591 std::unique_ptr<ScriptCompiler::CachedData> new_cached_data;
15931592 if (produce_cached_data) {
@@ -1600,7 +1599,7 @@ Local<Object> ContextifyContext::CompileFunctionAndCacheResult(
16001599 produce_cached_data,
16011600 std::move (new_cached_data))
16021601 .IsNothing ()) {
1603- return Object::New (env-> isolate ()) ;
1602+ return {} ;
16041603 }
16051604
16061605 return result;
0 commit comments