Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Van Sande <sebastian@vansande.org>2017-02-11 22:32:16 +0300
committerMichael Dawson <michael_dawson@ca.ibm.com>2017-06-07 00:20:23 +0300
commitdcfbbacba8c22613b956c1a3b9d958676e5d5e87 (patch)
treef9ea9757b3874f2e21149b968c4fdbda8a4dd621 /lib/path.js
parent4c5cbb7c8367abde6409ce68eee0e5eb5f07903d (diff)
path: use internal/errors.js
PR-URL: https://github.com/nodejs/node/pull/11319 Ref: https://github.com/nodejs/node/issues/11273 Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Diffstat (limited to 'lib/path.js')
-rw-r--r--lib/path.js18
1 files changed, 8 insertions, 10 deletions
diff --git a/lib/path.js b/lib/path.js
index 2f67c8cadc8..f8d0e822bf1 100644
--- a/lib/path.js
+++ b/lib/path.js
@@ -21,11 +21,11 @@
'use strict';
-const inspect = require('util').inspect;
+const errors = require('internal/errors');
function assertPath(path) {
if (typeof path !== 'string') {
- throw new TypeError('Path must be a string. Received ' + inspect(path));
+ throw new errors.TypeError('ERR_INVALID_ARG_TYPE', 'path', 'string');
}
}
@@ -816,7 +816,7 @@ const win32 = {
basename: function basename(path, ext) {
if (ext !== undefined && typeof ext !== 'string')
- throw new TypeError('"ext" argument must be a string');
+ throw new errors.TypeError('ERR_INVALID_ARG_TYPE', 'ext', 'string');
assertPath(path);
var start = 0;
var end = -1;
@@ -959,9 +959,8 @@ const win32 = {
format: function format(pathObject) {
if (pathObject === null || typeof pathObject !== 'object') {
- throw new TypeError(
- `Parameter "pathObject" must be an object, not ${typeof pathObject}`
- );
+ throw new errors.TypeError('ERR_INVALID_ARG_TYPE', 'pathObject', 'Object',
+ typeof pathObject);
}
return _format('\\', pathObject);
},
@@ -1372,7 +1371,7 @@ const posix = {
basename: function basename(path, ext) {
if (ext !== undefined && typeof ext !== 'string')
- throw new TypeError('"ext" argument must be a string');
+ throw new errors.TypeError('ERR_INVALID_ARG_TYPE', 'ext', 'string');
assertPath(path);
var start = 0;
@@ -1503,9 +1502,8 @@ const posix = {
format: function format(pathObject) {
if (pathObject === null || typeof pathObject !== 'object') {
- throw new TypeError(
- `Parameter "pathObject" must be an object, not ${typeof pathObject}`
- );
+ throw new errors.TypeError('ERR_INVALID_ARG_TYPE', 'pathObject', 'Object',
+ typeof pathObject);
}
return _format('/', pathObject);
},