diff --git a/src/node.cc b/src/node.cc index d3749b9cc12937..1da6cc7dd30278 100644 --- a/src/node.cc +++ b/src/node.cc @@ -1578,7 +1578,7 @@ static void Chdir(const FunctionCallbackInfo& args) { node::Utf8Value path(args.GetIsolate(), args[0]); int err = uv_chdir(*path); if (err) { - return env->ThrowUVException(err, "uv_chdir"); + return env->ThrowUVException(err, "chdir", nullptr, *path, nullptr); } } diff --git a/test/parallel/test-fs-chdir-errormessage.js b/test/parallel/test-fs-chdir-errormessage.js new file mode 100644 index 00000000000000..e511688cc76bd9 --- /dev/null +++ b/test/parallel/test-fs-chdir-errormessage.js @@ -0,0 +1,14 @@ +'use strict'; + +const { expectsError } = require('../common'); + +expectsError( + () => { + process.chdir('does-not-exist'); + }, + { + type: Error, + code: 'ENOENT', + message: "ENOENT: no such file or directory, chdir 'does-not-exist'", + } +);