Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 3f62f99

Browse filesBrowse files
jasnelldanielleadams
authored andcommitted
src: more idiomatic error pattern in node_wasi
Signed-off-by: James M Snell <jasnell@gmail.com> PR-URL: #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>
1 parent 392c881 commit 3f62f99
Copy full SHA for 3f62f99

File tree

Expand file treeCollapse file tree

1 file changed

+6
-8
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+6
-8
lines changed
Open diff view settings
Collapse file

‎src/node_wasi.cc‎

Copy file name to clipboardExpand all lines: src/node_wasi.cc
+6-8Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,9 @@ static MaybeLocal<Value> WASIException(Local<Context> context,
104104
js_msg =
105105
String::Concat(isolate, js_msg, FIXED_ONE_BYTE_STRING(isolate, ", "));
106106
js_msg = String::Concat(isolate, js_msg, js_syscall);
107-
Local<Object> e =
108-
Exception::Error(js_msg)->ToObject(context)
109-
.ToLocalChecked();
107+
Local<Object> e;
108+
if (!Exception::Error(js_msg)->ToObject(context).ToLocal(&e))
109+
return MaybeLocal<Value>();
110110

111111
if (e->Set(context,
112112
env->errno_string(),
@@ -128,13 +128,11 @@ WASI::WASI(Environment* env,
128128
options->allocator = &alloc_info_;
129129
int err = uvwasi_init(&uvw_, options);
130130
if (err != UVWASI_ESUCCESS) {
131-
Local<Context> context = env->context();
132-
MaybeLocal<Value> exception = WASIException(context, err, "uvwasi_init");
133-
134-
if (exception.IsEmpty())
131+
Local<Value> exception;
132+
if (!WASIException(env->context(), err, "uvwasi_init").ToLocal(&exception))
135133
return;
136134

137-
context->GetIsolate()->ThrowException(exception.ToLocalChecked());
135+
env->isolate()->ThrowException(exception);
138136
}
139137
}
140138

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.