@@ -252,19 +252,14 @@ void Hash::OneShotDigest(const FunctionCallbackInfo<Value>& args) {
252252 return ThrowCryptoError (env, ERR_get_error ());
253253 }
254254
255- Local<Value> error;
256- MaybeLocal<Value> rc =
257- StringBytes::Encode (env->isolate (),
255+ Local<Value> ret;
256+ if (StringBytes::Encode (env->isolate (),
258257 static_cast <const char *>(output.get ()),
259258 output.size (),
260- output_enc,
261- &error);
262- if (rc.IsEmpty ()) [[unlikely]] {
263- CHECK (!error.IsEmpty ());
264- env->isolate ()->ThrowException (error);
265- return ;
259+ output_enc)
260+ .ToLocal (&ret)) {
261+ args.GetReturnValue ().Set (ret);
266262 }
267- args.GetReturnValue ().Set (rc.FromMaybe (Local<Value>()));
268263}
269264
270265void Hash::Initialize (Environment* env, Local<Object> target) {
@@ -410,15 +405,12 @@ void Hash::HashDigest(const FunctionCallbackInfo<Value>& args) {
410405 hash->digest_ = ByteSource::Allocated (data.release ());
411406 }
412407
413- Local<Value> error;
414- MaybeLocal<Value> rc = StringBytes::Encode (
415- env->isolate (), hash->digest_ .data <char >(), len, encoding, &error);
416- if (rc.IsEmpty ()) [[unlikely]] {
417- CHECK (!error.IsEmpty ());
418- env->isolate ()->ThrowException (error);
419- return ;
408+ Local<Value> ret;
409+ if (StringBytes::Encode (
410+ env->isolate (), hash->digest_ .data <char >(), len, encoding)
411+ .ToLocal (&ret)) {
412+ args.GetReturnValue ().Set (ret);
420413 }
421- args.GetReturnValue ().Set (rc.FromMaybe (Local<Value>()));
422414}
423415
424416HashConfig::HashConfig (HashConfig&& other) noexcept
@@ -541,19 +533,14 @@ void InternalVerifyIntegrity(const v8::FunctionCallbackInfo<v8::Value>& args) {
541533
542534 if (digest_size != expected.size () ||
543535 CRYPTO_memcmp (digest, expected.data (), digest_size) != 0 ) {
544- Local<Value> error;
545- MaybeLocal<Value> rc =
546- StringBytes::Encode (env->isolate (),
536+ Local<Value> ret;
537+ if (StringBytes::Encode (env->isolate (),
547538 reinterpret_cast <const char *>(digest),
548539 digest_size,
549- BASE64,
550- &error);
551- if (rc.IsEmpty ()) [[unlikely]] {
552- CHECK (!error.IsEmpty ());
553- env->isolate ()->ThrowException (error);
554- return ;
540+ BASE64)
541+ .ToLocal (&ret)) {
542+ args.GetReturnValue ().Set (ret);
555543 }
556- args.GetReturnValue ().Set (rc.FromMaybe (Local<Value>()));
557544 }
558545}
559546} // namespace crypto
0 commit comments