process: unify error message from chdir() errors
PR-URL: https://github.com/nodejs/node/pull/19088 Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
This commit is contained in:
parent
13861da9c0
commit
b32bcf7e9c
@ -1580,7 +1580,7 @@ static void Chdir(const FunctionCallbackInfo<Value>& args) {
|
|||||||
node::Utf8Value path(args.GetIsolate(), args[0]);
|
node::Utf8Value path(args.GetIsolate(), args[0]);
|
||||||
int err = uv_chdir(*path);
|
int err = uv_chdir(*path);
|
||||||
if (err) {
|
if (err) {
|
||||||
return env->ThrowUVException(err, "uv_chdir");
|
return env->ThrowUVException(err, "chdir", nullptr, *path, nullptr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
14
test/parallel/test-fs-chdir-errormessage.js
Normal file
14
test/parallel/test-fs-chdir-errormessage.js
Normal file
@ -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'",
|
||||||
|
}
|
||||||
|
);
|
Loading…
x
Reference in New Issue
Block a user