diff options
author | starkwang <381152119@qq.com> | 2017-06-29 00:12:12 +0800 |
---|---|---|
committer | Refael Ackermann <refack@gmail.com> | 2017-07-01 22:32:32 -0400 |
commit | 473f0eff29c84aeb19ae1fb7898bc99321ac5754 (patch) | |
tree | 65f2934f24d058b22c260b92e3720318daffcbda /lib/url.js | |
parent | fc463639fa38434a3360a1e3695d7ded029242c3 (diff) | |
download | android-node-v8-473f0eff29c84aeb19ae1fb7898bc99321ac5754.tar.gz android-node-v8-473f0eff29c84aeb19ae1fb7898bc99321ac5754.tar.bz2 android-node-v8-473f0eff29c84aeb19ae1fb7898bc99321ac5754.zip |
errors,url: port url errors to internal/errors
PR-URL: https://github.com/nodejs/node/pull/13963
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Timothy Gu <timothygu99@gmail.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'lib/url.js')
-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 ? |