From 33421de96393319267ab64003d95bac2edd8f58e Mon Sep 17 00:00:00 2001 From: Bougarfaoui El houcine Date: Mon, 13 Feb 2017 15:55:27 +0000 Subject: [PATCH 1/3] port internal/net errors to internal/errors --- lib/internal/net.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/internal/net.js b/lib/internal/net.js index d19bc4c219a796..94ca49418e1888 100644 --- a/lib/internal/net.js +++ b/lib/internal/net.js @@ -1,5 +1,7 @@ 'use strict'; +const errors = require('internal/errors'); + module.exports = { isLegalPort, assertPort }; // Check that the port number is not NaN when coerced to a number, @@ -14,5 +16,5 @@ function isLegalPort(port) { function assertPort(port) { if (typeof port !== 'undefined' && !isLegalPort(port)) - throw new RangeError('"port" argument must be >= 0 and < 65536'); + throw errors.RangeError('ERR_PORT_ARGUMENT',port); } From 96254978ee5fa2e86ec7eee4a42a88d00b0fbd05 Mon Sep 17 00:00:00 2001 From: Bougarfaoui El houcine Date: Mon, 13 Feb 2017 16:42:45 +0000 Subject: [PATCH 2/3] add ERR_UNABLE_TRSC_BUFF error --- lib/internal/errors.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/internal/errors.js b/lib/internal/errors.js index f2376f70371c60..7f65062f53120e 100644 --- a/lib/internal/errors.js +++ b/lib/internal/errors.js @@ -86,3 +86,4 @@ module.exports = exports = { // Note: Please try to keep these in alphabetical order E('ERR_ASSERTION', (msg) => msg); // Add new errors from here... +E('ERR_UNABLE_TRSC_BUFF', `Unable to transcode Buffer [%s]`); From 0a3fcff23870af8e6b6499f6e2831997163c5e23 Mon Sep 17 00:00:00 2001 From: Bougarfaoui El houcine Date: Mon, 13 Feb 2017 16:43:29 +0000 Subject: [PATCH 3/3] errors: port internal/buffer errors to internal/errors --- lib/internal/buffer.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/internal/buffer.js b/lib/internal/buffer.js index 744bf2dcab6ec4..c6b47c291e5b24 100644 --- a/lib/internal/buffer.js +++ b/lib/internal/buffer.js @@ -1,5 +1,7 @@ 'use strict'; +const errors = require('internal/errors'); + if (!process.binding('config').hasIntl) { return; } @@ -24,7 +26,7 @@ exports.transcode = function transcode(source, fromEncoding, toEncoding) { return result; const code = icu.icuErrName(result); - const err = new Error(`Unable to transcode Buffer [${code}]`); + const err = new errors.Error('ERR_UNABLE_TRSC_BUFF',code); err.code = code; err.errno = result; throw err;