@@ -1501,24 +1501,22 @@ void ContextifyContext::CompileFunction(
1501
1501
}
1502
1502
1503
1503
TryCatchScope try_catch (env);
1504
- Local<Object> result = CompileFunctionAndCacheResult (env,
1505
- parsing_context,
1506
- &source,
1507
- params,
1508
- context_extensions,
1509
- options,
1510
- produce_cached_data,
1511
- id_symbol,
1512
- try_catch);
1513
-
1514
- if (try_catch.HasCaught () && !try_catch.HasTerminated ()) {
1504
+ MaybeLocal<Object> maybe_result =
1505
+ CompileFunctionAndCacheResult (env,
1506
+ parsing_context,
1507
+ &source,
1508
+ params,
1509
+ context_extensions,
1510
+ options,
1511
+ produce_cached_data,
1512
+ id_symbol,
1513
+ try_catch);
1514
+ Local<Object> result;
1515
+ if (!maybe_result.ToLocal (&result)) {
1516
+ CHECK (try_catch.HasCaught ());
1515
1517
try_catch.ReThrow ();
1516
1518
return ;
1517
1519
}
1518
-
1519
- if (result.IsEmpty ()) {
1520
- return ;
1521
- }
1522
1520
args.GetReturnValue ().Set (result);
1523
1521
}
1524
1522
@@ -1534,7 +1532,7 @@ static LocalVector<String> GetCJSParameters(IsolateData* data) {
1534
1532
return result;
1535
1533
}
1536
1534
1537
- Local <Object> ContextifyContext::CompileFunctionAndCacheResult (
1535
+ MaybeLocal <Object> ContextifyContext::CompileFunctionAndCacheResult (
1538
1536
Environment* env,
1539
1537
Local<Context> parsing_context,
1540
1538
ScriptCompiler::Source* source,
@@ -1556,28 +1554,29 @@ Local<Object> ContextifyContext::CompileFunctionAndCacheResult(
1556
1554
1557
1555
Local<Function> fn;
1558
1556
if (!maybe_fn.ToLocal (&fn)) {
1559
- if (try_catch.HasCaught () && !try_catch.HasTerminated ()) {
1557
+ CHECK (try_catch.HasCaught ());
1558
+ if (!try_catch.HasTerminated ()) {
1560
1559
errors::DecorateErrorStack (env, try_catch);
1561
- return Object::New (env->isolate ());
1562
1560
}
1561
+ return {};
1563
1562
}
1564
1563
1565
1564
Local<Context> context = env->context ();
1566
1565
if (fn->SetPrivate (context, env->host_defined_option_symbol (), id_symbol)
1567
1566
.IsNothing ()) {
1568
- return Object::New (env-> isolate ()) ;
1567
+ return {} ;
1569
1568
}
1570
1569
1571
1570
Isolate* isolate = env->isolate ();
1572
1571
Local<Object> result = Object::New (isolate);
1573
1572
if (result->Set (parsing_context, env->function_string (), fn).IsNothing ())
1574
- return Object::New (env-> isolate ()) ;
1573
+ return {} ;
1575
1574
if (result
1576
1575
->Set (parsing_context,
1577
1576
env->source_map_url_string (),
1578
1577
fn->GetScriptOrigin ().SourceMapUrl ())
1579
1578
.IsNothing ())
1580
- return Object::New (env-> isolate ()) ;
1579
+ return {} ;
1581
1580
1582
1581
std::unique_ptr<ScriptCompiler::CachedData> new_cached_data;
1583
1582
if (produce_cached_data) {
@@ -1590,7 +1589,7 @@ Local<Object> ContextifyContext::CompileFunctionAndCacheResult(
1590
1589
produce_cached_data,
1591
1590
std::move (new_cached_data))
1592
1591
.IsNothing ()) {
1593
- return Object::New (env-> isolate ()) ;
1592
+ return {} ;
1594
1593
}
1595
1594
1596
1595
return result;
0 commit comments