Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

src: minor error cleanups #35493

Merged
merged 2 commits into from Oct 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 6 additions & 8 deletions src/node_wasi.cc
Expand Up @@ -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(),
Expand All @@ -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);
}
}

Expand Down
4 changes: 1 addition & 3 deletions src/pipe_wrap.cc
Expand Up @@ -40,7 +40,6 @@ using v8::Function;
using v8::FunctionCallbackInfo;
using v8::FunctionTemplate;
using v8::Int32;
using v8::Isolate;
using v8::Local;
using v8::MaybeLocal;
using v8::Object;
Expand Down Expand Up @@ -216,9 +215,8 @@ void PipeWrap::Open(const FunctionCallbackInfo<Value>& args) {
int err = uv_pipe_open(&wrap->handle_, fd);
wrap->set_fd(fd);

Isolate* isolate = env->isolate();
if (err != 0)
isolate->ThrowException(UVException(isolate, err, "uv_pipe_open"));
env->ThrowUVException(err, "uv_pipe_open");
}


Expand Down