From 5cdc716d1493ec11e91548dcaf87721f180ca435 Mon Sep 17 00:00:00 2001 From: Sarat Addepalli Date: Fri, 2 Mar 2018 21:01:51 +0530 Subject: [PATCH 1/2] process: unify error message from chdir() errors --- src/node.cc | 2 +- test/parallel/test-fs-chdir-errormessage.js | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 test/parallel/test-fs-chdir-errormessage.js 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..4dfb636377afd1 --- /dev/null +++ b/test/parallel/test-fs-chdir-errormessage.js @@ -0,0 +1,19 @@ +'use strict'; + +require('../common'); +const process = require('process'); +const assert = require('assert'); + +assert.throws( + () => { + process.chdir('does-not-exist'); + }, + (error) => { + assert.strictEqual(error instanceof Error, true); + assert.strictEqual( + error.message, + "ENOENT: no such file or directory, chdir 'does-not-exist'" + ); + return true; + } +); From ba28e9705835d9baf2cb2b06b9e22d002096b145 Mon Sep 17 00:00:00 2001 From: Sarat Addepalli Date: Fri, 2 Mar 2018 23:03:17 +0530 Subject: [PATCH 2/2] process: review comments for error message changes --- test/parallel/test-fs-chdir-errormessage.js | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/test/parallel/test-fs-chdir-errormessage.js b/test/parallel/test-fs-chdir-errormessage.js index 4dfb636377afd1..e511688cc76bd9 100644 --- a/test/parallel/test-fs-chdir-errormessage.js +++ b/test/parallel/test-fs-chdir-errormessage.js @@ -1,19 +1,14 @@ 'use strict'; -require('../common'); -const process = require('process'); -const assert = require('assert'); +const { expectsError } = require('../common'); -assert.throws( +expectsError( () => { process.chdir('does-not-exist'); }, - (error) => { - assert.strictEqual(error instanceof Error, true); - assert.strictEqual( - error.message, - "ENOENT: no such file or directory, chdir 'does-not-exist'" - ); - return true; + { + type: Error, + code: 'ENOENT', + message: "ENOENT: no such file or directory, chdir 'does-not-exist'", } );