diff --git a/src/util.cc b/src/util.cc index a372eb4d88ca1d..8bf239db6e47d4 100644 --- a/src/util.cc +++ b/src/util.cc @@ -782,6 +782,16 @@ std::string DetermineSpecificErrorType(Environment* env, input.As()->GetConstructorName(); Utf8Value name(env->isolate(), constructor_name); return SPrintF("an instance of %s", name.out()); + } else if (input->IsSymbol()) { + v8::MaybeLocal str = + input.As()->ToDetailString(env->context()); + v8::Local 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(), diff --git a/test/parallel/test-fs-stat.js b/test/parallel/test-fs-stat.js index 46874086d58dc7..b9d42b5b61bc83 100644 --- a/test/parallel/test-fs-stat.js +++ b/test/parallel/test-fs-stat.js @@ -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', + }, + ); +}