diff --git a/src/node_wasi.cc b/src/node_wasi.cc index b8539a9395e8b3..fb965d90fbef31 100644 --- a/src/node_wasi.cc +++ b/src/node_wasi.cc @@ -103,9 +103,9 @@ static MaybeLocal WASIException(Local context, js_msg = String::Concat(isolate, js_msg, FIXED_ONE_BYTE_STRING(isolate, ", ")); js_msg = String::Concat(isolate, js_msg, js_syscall); - Local e = - Exception::Error(js_msg)->ToObject(context) - .ToLocalChecked(); + Local e; + if (!Exception::Error(js_msg)->ToObject(context).ToLocal(&e)) + return MaybeLocal(); if (e->Set(context, env->errno_string(), @@ -127,13 +127,11 @@ WASI::WASI(Environment* env, options->allocator = &alloc_info_; int err = uvwasi_init(&uvw_, options); if (err != UVWASI_ESUCCESS) { - Local context = env->context(); - MaybeLocal exception = WASIException(context, err, "uvwasi_init"); - - if (exception.IsEmpty()) + Local exception; + if (!WASIException(env->context(), err, "uvwasi_init").ToLocal(&exception)) return; - context->GetIsolate()->ThrowException(exception.ToLocalChecked()); + env->isolate()->ThrowException(exception); } }