From b32bcf7e9c4f7f1fa5433b44d2a0933692cf0951 Mon Sep 17 00:00:00 2001 From: Sarat Addepalli Date: Fri, 2 Mar 2018 21:01:51 +0530 Subject: [PATCH] process: unify error message from chdir() errors PR-URL: https://github.com/nodejs/node/pull/19088 Reviewed-By: Joyee Cheung Reviewed-By: Colin Ihrig Reviewed-By: Richard Lau Reviewed-By: James M Snell Reviewed-By: Matteo Collina Reviewed-By: Anna Henningsen Reviewed-By: Sakthipriyan Vairamani --- src/node.cc | 2 +- test/parallel/test-fs-chdir-errormessage.js | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 test/parallel/test-fs-chdir-errormessage.js diff --git a/src/node.cc b/src/node.cc index 64de859bc6a..20c5da46d66 100644 --- a/src/node.cc +++ b/src/node.cc @@ -1580,7 +1580,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 00000000000..e511688cc76 --- /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'", + } +);