Skip to content

Commit

Permalink
src: fix check fd
Browse files Browse the repository at this point in the history
  • Loading branch information
theanarkh committed Nov 26, 2024
1 parent 87da1f3 commit 37b5cac
Show file tree
Hide file tree
Showing 2 changed files with 21 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 @@ -782,6 +782,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
11 changes: 11 additions & 0 deletions test/parallel/test-fs-stat.js
Original file line number Diff line number Diff line change
Expand Up @@ -212,3 +212,14 @@ fs.lstat(__filename, undefined, common.mustCall());
assert.strictEqual(s.birthtime, 5);
}));
}

{
assert.throws(
() => fs.fstat(Symbol("test"), () => {}),

Check failure on line 218 in test/parallel/test-fs-stat.js

View workflow job for this annotation

GitHub Actions / lint-js-and-md

Strings must use singlequote
{
code: 'ERR_INVALID_ARG_TYPE',
name: 'TypeError',
message: 'The "fd" argument must be of type number. Received Symbol(test)',
}
);

Check failure on line 224 in test/parallel/test-fs-stat.js

View workflow job for this annotation

GitHub Actions / lint-js-and-md

Trailing spaces not allowed
}

0 comments on commit 37b5cac

Please sign in to comment.