Skip to content

Commit

Permalink
src: fix check fd
Browse files Browse the repository at this point in the history
PR-URL: #56000
Fixes: #55983
Reviewed-By: Yagiz Nizipli <[email protected]>
Reviewed-By: Antoine du Hamel <[email protected]>
Reviewed-By: Jason Zhang <[email protected]>
Reviewed-By: Juan José Arboleda <[email protected]>
  • Loading branch information
theanarkh authored and aduh95 committed Dec 18, 2024
1 parent afc7fb3 commit b5ddedb
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -760,6 +760,16 @@ std::string DetermineSpecificErrorType(Environment* env,
input.As<v8::Object>()->GetConstructorName();
Utf8Value name(env->isolate(), constructor_name);
return SPrintF("an instance of %s", name.out());
} else if (input->IsSymbol()) {
v8::MaybeLocal<v8::String> str =
input.As<v8::Symbol>()->ToDetailString(env->context());
v8::Local<v8::String> js_str;
if (!str.ToLocal(&js_str)) {
return "Symbol";
}
Utf8Value name(env->isolate(), js_str);
// Symbol(xxx)
return name.out();
}

Utf8Value utf8_value(env->isolate(),
Expand Down
9 changes: 9 additions & 0 deletions test/parallel/test-fs-stat.js
Original file line number Diff line number Diff line change
Expand Up @@ -212,3 +212,12 @@ fs.lstat(__filename, undefined, common.mustCall());
assert.strictEqual(s.birthtime, 5);
}));
}

{
assert.throws(
() => fs.fstat(Symbol('test'), () => {}),
{
code: 'ERR_INVALID_ARG_TYPE',
},
);
}

0 comments on commit b5ddedb

Please sign in to comment.