Skip to content

Commit

Permalink
src: use Maybe<void> in node::crypto::error
Browse files Browse the repository at this point in the history
With recent versions of V8, it is not necessary to use Maybe<bool>
anymore.

PR-URL: nodejs#53766
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Yagiz Nizipli <yagiz.nizipli@sentry.io>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
tniessen committed Jul 10, 2024
1 parent fd21dd4 commit a848206
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions src/crypto/crypto_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ using v8::Exception;
using v8::FunctionCallbackInfo;
using v8::HandleScope;
using v8::Isolate;
using v8::Just;
using v8::JustVoid;
using v8::Local;
using v8::Maybe;
using v8::MaybeLocal;
Expand Down Expand Up @@ -457,9 +457,10 @@ ByteSource ByteSource::Foreign(const void* data, size_t size) {
}

namespace error {
Maybe<bool> Decorate(Environment* env, Local<Object> obj,
unsigned long err) { // NOLINT(runtime/int)
if (err == 0) return Just(true); // No decoration necessary.
Maybe<void> Decorate(Environment* env,
Local<Object> obj,
unsigned long err) { // NOLINT(runtime/int)
if (err == 0) return JustVoid(); // No decoration necessary.

const char* ls = ERR_lib_error_string(err);
const char* fs = ERR_func_error_string(err);
Expand All @@ -471,19 +472,19 @@ Maybe<bool> Decorate(Environment* env, Local<Object> obj,
if (ls != nullptr) {
if (obj->Set(context, env->library_string(),
OneByteString(isolate, ls)).IsNothing()) {
return Nothing<bool>();
return Nothing<void>();
}
}
if (fs != nullptr) {
if (obj->Set(context, env->function_string(),
OneByteString(isolate, fs)).IsNothing()) {
return Nothing<bool>();
return Nothing<void>();
}
}
if (rs != nullptr) {
if (obj->Set(context, env->reason_string(),
OneByteString(isolate, rs)).IsNothing()) {
return Nothing<bool>();
return Nothing<void>();
}

// SSL has no API to recover the error name from the number, so we
Expand Down Expand Up @@ -556,10 +557,10 @@ Maybe<bool> Decorate(Environment* env, Local<Object> obj,
if (obj->Set(env->isolate()->GetCurrentContext(),
env->code_string(),
OneByteString(env->isolate(), code)).IsNothing())
return Nothing<bool>();
return Nothing<void>();
}

return Just(true);
return JustVoid();
}
} // namespace error

Expand Down

0 comments on commit a848206

Please sign in to comment.