Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src/api
diff options
context:
space:
mode:
authorSam Roberts <vieuxtech@gmail.com>2019-04-10 01:21:36 +0300
committerSam Roberts <vieuxtech@gmail.com>2019-04-12 22:33:37 +0300
commit060d901f87b3d87314f8540eb02f315e2952f581 (patch)
tree53159171201703bb6d8a4e780c8624a5c6c8cbb5 /src/api
parent7b0d8673898e65a368108264c77bccaa3e004028 (diff)
src: replace FromJust() with Check() when possible
FromJust() is often used not for its return value, but for its side-effects. In these cases, Check() exists, and is more clear as to the intent. From its comment: To be used, where the actual value of the Maybe is not needed, like Object::Set. See: https://github.com/nodejs/node/pull/26929/files#r269256335 PR-URL: https://github.com/nodejs/node/pull/27162 Reviewed-By: Anatoli Papirovski <apapirovski@mac.com> Reviewed-By: Michaƫl Zasso <targos@protonmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com>
Diffstat (limited to 'src/api')
-rw-r--r--src/api/exceptions.cc24
-rw-r--r--src/api/hooks.cc2
2 files changed, 13 insertions, 13 deletions
diff --git a/src/api/exceptions.cc b/src/api/exceptions.cc
index 1025991063e..ee5ea984eb2 100644
--- a/src/api/exceptions.cc
+++ b/src/api/exceptions.cc
@@ -58,17 +58,17 @@ Local<Value> ErrnoException(Isolate* isolate,
Local<Object> obj = e.As<Object>();
obj->Set(env->context(),
env->errno_string(),
- Integer::New(isolate, errorno)).FromJust();
- obj->Set(env->context(), env->code_string(), estring).FromJust();
+ Integer::New(isolate, errorno)).Check();
+ obj->Set(env->context(), env->code_string(), estring).Check();
if (path_string.IsEmpty() == false) {
- obj->Set(env->context(), env->path_string(), path_string).FromJust();
+ obj->Set(env->context(), env->path_string(), path_string).Check();
}
if (syscall != nullptr) {
obj->Set(env->context(),
env->syscall_string(),
- OneByteString(isolate, syscall)).FromJust();
+ OneByteString(isolate, syscall)).Check();
}
return e;
@@ -144,13 +144,13 @@ Local<Value> UVException(Isolate* isolate,
e->Set(env->context(),
env->errno_string(),
- Integer::New(isolate, errorno)).FromJust();
- e->Set(env->context(), env->code_string(), js_code).FromJust();
- e->Set(env->context(), env->syscall_string(), js_syscall).FromJust();
+ Integer::New(isolate, errorno)).Check();
+ e->Set(env->context(), env->code_string(), js_code).Check();
+ e->Set(env->context(), env->syscall_string(), js_syscall).Check();
if (!js_path.IsEmpty())
- e->Set(env->context(), env->path_string(), js_path).FromJust();
+ e->Set(env->context(), env->path_string(), js_path).Check();
if (!js_dest.IsEmpty())
- e->Set(env->context(), env->dest_string(), js_dest).FromJust();
+ e->Set(env->context(), env->dest_string(), js_dest).Check();
return e;
}
@@ -219,21 +219,21 @@ Local<Value> WinapiErrnoException(Isolate* isolate,
Local<Object> obj = e.As<Object>();
obj->Set(env->context(), env->errno_string(), Integer::New(isolate, errorno))
- .FromJust();
+ .Check();
if (path != nullptr) {
obj->Set(env->context(),
env->path_string(),
String::NewFromUtf8(isolate, path, NewStringType::kNormal)
.ToLocalChecked())
- .FromJust();
+ .Check();
}
if (syscall != nullptr) {
obj->Set(env->context(),
env->syscall_string(),
OneByteString(isolate, syscall))
- .FromJust();
+ .Check();
}
if (must_free) {
diff --git a/src/api/hooks.cc b/src/api/hooks.cc
index 6a0319c61cc..3b1ee90a99a 100644
--- a/src/api/hooks.cc
+++ b/src/api/hooks.cc
@@ -49,7 +49,7 @@ int EmitExit(Environment* env) {
->Set(env->context(),
FIXED_ONE_BYTE_STRING(env->isolate(), "_exiting"),
True(env->isolate()))
- .FromJust();
+ .Check();
Local<String> exit_code = env->exit_code_string();
int code = process_object->Get(env->context(), exit_code)