diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/url.js | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/lib/url.js b/lib/url.js index 2c9bc58ab5..fcddd4afaf 100644 --- a/lib/url.js +++ b/lib/url.js @@ -26,6 +26,8 @@ const { toASCII } = process.binding('config').hasIntl ? const { hexTable } = require('internal/querystring'); +const errors = require('internal/errors'); + // WHATWG URL implementation provided by internal/url const { URL, @@ -99,7 +101,7 @@ function urlParse(url, parseQueryString, slashesDenoteHost) { Url.prototype.parse = function parse(url, parseQueryString, slashesDenoteHost) { if (typeof url !== 'string') { - throw new TypeError('Parameter "url" must be a string, not ' + typeof url); + throw new errors.TypeError('ERR_INVALID_ARG_TYPE', 'url', 'string', url); } // Copy chrome, IE, opera backslash-handling behavior. @@ -556,8 +558,7 @@ function urlFormat(obj, options) { if (typeof obj === 'string') { obj = urlParse(obj); } else if (typeof obj !== 'object' || obj === null) { - throw new TypeError('Parameter "urlObj" must be an object, not ' + - (obj === null ? 'null' : typeof obj)); + throw new errors.TypeError('ERR_INVALID_ARG_TYPE', 'urlObj', 'object', obj); } else if (!(obj instanceof Url)) { var format = obj[formatSymbol]; return format ? |