mirror of https://github.com/nodejs/node.git
src: more idiomatic error pattern in node_wasi
Signed-off-by: James M Snell <jasnell@gmail.com> PR-URL: https://github.com/nodejs/node/pull/35493 Reviewed-By: Daijiro Wachi <daijiro.wachi@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: David Carlier <devnexen@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Rich Trott <rtrott@gmail.com>pull/35493/head
parent
530acd1071
commit
8beef5eeb8
|
@ -104,9 +104,9 @@ static MaybeLocal<Value> WASIException(Local<Context> context,
|
|||
js_msg =
|
||||
String::Concat(isolate, js_msg, FIXED_ONE_BYTE_STRING(isolate, ", "));
|
||||
js_msg = String::Concat(isolate, js_msg, js_syscall);
|
||||
Local<Object> e =
|
||||
Exception::Error(js_msg)->ToObject(context)
|
||||
.ToLocalChecked();
|
||||
Local<Object> e;
|
||||
if (!Exception::Error(js_msg)->ToObject(context).ToLocal(&e))
|
||||
return MaybeLocal<Value>();
|
||||
|
||||
if (e->Set(context,
|
||||
env->errno_string(),
|
||||
|
@ -128,13 +128,11 @@ WASI::WASI(Environment* env,
|
|||
options->allocator = &alloc_info_;
|
||||
int err = uvwasi_init(&uvw_, options);
|
||||
if (err != UVWASI_ESUCCESS) {
|
||||
Local<Context> context = env->context();
|
||||
MaybeLocal<Value> exception = WASIException(context, err, "uvwasi_init");
|
||||
|
||||
if (exception.IsEmpty())
|
||||
Local<Value> exception;
|
||||
if (!WASIException(env->context(), err, "uvwasi_init").ToLocal(&exception))
|
||||
return;
|
||||
|
||||
context->GetIsolate()->ThrowException(exception.ToLocalChecked());
|
||||
env->isolate()->ThrowException(exception);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue