diff options
author | Yaniv Friedensohn <yaniv.friedensohn@gmail.com> | 2019-05-11 20:00:38 +0300 |
---|---|---|
committer | Rich Trott <rtrott@gmail.com> | 2019-08-10 01:58:58 +0300 |
commit | a0e2c6d2843ea6e37035a949827cdcc7949026d6 (patch) | |
tree | 8324272d3272db9c67a81d16c1dfd0e225069248 /src/node_crypto.cc | |
parent | c065773cc56080b48ff4e29822152679f7db5573 (diff) |
src: add error codes to errors thrown in C++
PR-URL: https://github.com/nodejs/node/pull/27700
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Diffstat (limited to 'src/node_crypto.cc')
-rw-r--r-- | src/node_crypto.cc | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/src/node_crypto.cc b/src/node_crypto.cc index 70da2e310ea..f1c7d1796ac 100644 --- a/src/node_crypto.cc +++ b/src/node_crypto.cc @@ -4317,8 +4317,9 @@ void CipherBase::Update(const FunctionCallbackInfo<Value>& args) { // Only copy the data if we have to, because it's a string if (args[0]->IsString()) { StringBytes::InlineDecoder decoder; - if (!decoder.Decode(env, args[0].As<String>(), args[1], UTF8) - .FromMaybe(false)) + enum encoding enc = ParseEncoding(env->isolate(), args[1], UTF8); + + if (decoder.Decode(env, args[0].As<String>(), enc).IsNothing()) return; r = cipher->Update(decoder.out(), decoder.size(), &out); } else { @@ -4501,8 +4502,9 @@ void Hmac::HmacUpdate(const FunctionCallbackInfo<Value>& args) { bool r = false; if (args[0]->IsString()) { StringBytes::InlineDecoder decoder; - if (decoder.Decode(env, args[0].As<String>(), args[1], UTF8) - .FromMaybe(false)) { + enum encoding enc = ParseEncoding(env->isolate(), args[1], UTF8); + + if (!decoder.Decode(env, args[0].As<String>(), enc).IsNothing()) { r = hmac->HmacUpdate(decoder.out(), decoder.size()); } } else { @@ -4626,8 +4628,9 @@ void Hash::HashUpdate(const FunctionCallbackInfo<Value>& args) { bool r = true; if (args[0]->IsString()) { StringBytes::InlineDecoder decoder; - if (!decoder.Decode(env, args[0].As<String>(), args[1], UTF8) - .FromMaybe(false)) { + enum encoding enc = ParseEncoding(env->isolate(), args[1], UTF8); + + if (decoder.Decode(env, args[0].As<String>(), enc).IsNothing()) { args.GetReturnValue().Set(false); return; } |