@@ -252,19 +252,14 @@ void Hash::OneShotDigest(const FunctionCallbackInfo<Value>& args) {
252
252
return ThrowCryptoError (env, ERR_get_error ());
253
253
}
254
254
255
- Local<Value> error;
256
- MaybeLocal<Value> rc =
257
- StringBytes::Encode (env->isolate (),
255
+ Local<Value> ret;
256
+ if (StringBytes::Encode (env->isolate (),
258
257
static_cast <const char *>(output.get ()),
259
258
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);
266
262
}
267
- args.GetReturnValue ().Set (rc.FromMaybe (Local<Value>()));
268
263
}
269
264
270
265
void Hash::Initialize (Environment* env, Local<Object> target) {
@@ -410,15 +405,12 @@ void Hash::HashDigest(const FunctionCallbackInfo<Value>& args) {
410
405
hash->digest_ = ByteSource::Allocated (data.release ());
411
406
}
412
407
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);
420
413
}
421
- args.GetReturnValue ().Set (rc.FromMaybe (Local<Value>()));
422
414
}
423
415
424
416
HashConfig::HashConfig (HashConfig&& other) noexcept
@@ -541,19 +533,14 @@ void InternalVerifyIntegrity(const v8::FunctionCallbackInfo<v8::Value>& args) {
541
533
542
534
if (digest_size != expected.size () ||
543
535
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 (),
547
538
reinterpret_cast <const char *>(digest),
548
539
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);
555
543
}
556
- args.GetReturnValue ().Set (rc.FromMaybe (Local<Value>()));
557
544
}
558
545
}
559
546
} // namespace crypto
0 commit comments