diff --git a/src/util.cc b/src/util.cc index 34263cc9f3dc06..3e9dfb4392fb3e 100644 --- a/src/util.cc +++ b/src/util.cc @@ -760,6 +760,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', + }, + ); +}