src: improve error handling in node_env_var.cc

PR-URL: https://github.com/nodejs/node/pull/57767
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
This commit is contained in:
Antoine du Hamel authored and RafaelGSS committed 2025-05-02 17:06:09 -03:00
1 parent 3edea66431
commit 2b0f65ed5f
1 file changed
+5 -6
+5 -6
View File
@@ -436,15 +436,14 @@ static Intercepted EnvGetter(Local<Name> property,
MaybeLocal<String> value_string =
env->env_vars()->Get(env->isolate(), property.As<String>());
bool has_env = !value_string.IsEmpty();
TraceEnvVar(env, "get", property.As<String>());
if (has_env) {
// ToLocalChecked here is ok since we check IsEmpty above.
info.GetReturnValue().Set(value_string.ToLocalChecked());
return Intercepted::kYes;
Local<Value> ret;
if (!value_string.ToLocal(&ret)) {
return Intercepted::kNo;
}
return Intercepted::kNo;
info.GetReturnValue().Set(ret);
return Intercepted::kYes;
}
static Intercepted EnvSetter(Local<Name> property,