Skip to content

Commit d63fd86

Browse files
committed
src: fix check fd
1 parent 87da1f3 commit d63fd86

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

src/util.cc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -782,6 +782,16 @@ std::string DetermineSpecificErrorType(Environment* env,
782782
input.As<v8::Object>()->GetConstructorName();
783783
Utf8Value name(env->isolate(), constructor_name);
784784
return SPrintF("an instance of %s", name.out());
785+
} else if (input->IsSymbol()) {
786+
v8::MaybeLocal<v8::String> str =
787+
input.As<v8::Symbol>()->ToDetailString(env->context());
788+
v8::Local<v8::String> js_str;
789+
if (!str.ToLocal(&js_str)) {
790+
return "Symbol";
791+
}
792+
Utf8Value name(env->isolate(), js_str);
793+
// Symbol(xxx)
794+
return name.out();
785795
}
786796

787797
Utf8Value utf8_value(env->isolate(),

test/parallel/test-fs-stat.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,3 +212,14 @@ fs.lstat(__filename, undefined, common.mustCall());
212212
assert.strictEqual(s.birthtime, 5);
213213
}));
214214
}
215+
216+
{
217+
assert.throws(
218+
() => fs.fstat(Symbol('test'), () => {}),
219+
{
220+
code: 'ERR_INVALID_ARG_TYPE',
221+
name: 'TypeError',
222+
message: 'The "fd" argument must be of type number. Received Symbol(test)',
223+
}
224+
);
225+
}

0 commit comments

Comments
 (0)