From 1e8d110e640c658e4f6ed7540db62d063269ba6c Mon Sep 17 00:00:00 2001 From: Michaƫl Zasso Date: Tue, 27 Feb 2018 14:55:32 +0100 Subject: lib: port errors to new system This is a first batch of updates that touches non-underscored modules in lib. PR-URL: https://github.com/nodejs/node/pull/19034 Reviewed-By: James M Snell Reviewed-By: Ruben Bridgewater Reviewed-By: Joyee Cheung --- lib/url.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'lib/url.js') diff --git a/lib/url.js b/lib/url.js index ab4b2b4647..bb6637809a 100644 --- a/lib/url.js +++ b/lib/url.js @@ -26,7 +26,9 @@ const { toASCII } = process.binding('config').hasIntl ? const { hexTable } = require('internal/querystring'); -const errors = require('internal/errors'); +const { + ERR_INVALID_ARG_TYPE +} = require('internal/errors').codes; const { spliceOne } = require('internal/util'); @@ -103,7 +105,7 @@ function urlParse(url, parseQueryString, slashesDenoteHost) { Url.prototype.parse = function parse(url, parseQueryString, slashesDenoteHost) { if (typeof url !== 'string') { - throw new errors.TypeError('ERR_INVALID_ARG_TYPE', 'url', 'string', url); + throw new ERR_INVALID_ARG_TYPE('url', 'string', url); } // Copy chrome, IE, opera backslash-handling behavior. @@ -493,8 +495,8 @@ function urlFormat(urlObject, options) { if (typeof urlObject === 'string') { urlObject = urlParse(urlObject); } else if (typeof urlObject !== 'object' || urlObject === null) { - throw new errors.TypeError('ERR_INVALID_ARG_TYPE', 'urlObject', - ['Object', 'string'], urlObject); + throw new ERR_INVALID_ARG_TYPE('urlObject', + ['Object', 'string'], urlObject); } else if (!(urlObject instanceof Url)) { var format = urlObject[formatSymbol]; return format ? -- cgit v1.2.3