From bc5a0d3c058232daaf262157e35d84eecd6e4e07 Mon Sep 17 00:00:00 2001 From: ZYSzys <17367077526@163.com> Date: Fri, 2 Nov 2018 21:08:30 +0800 Subject: [PATCH] lib: gather all errors constant in the same place for consistency PR-URL: https://github.com/nodejs/node/pull/24038 Reviewed-By: Joyee Cheung Reviewed-By: James M Snell Reviewed-By: Luigi Pinca Reviewed-By: Colin Ihrig --- lib/net.js | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/lib/net.js b/lib/net.js index 9b139d28597b5c..3291ac92fb664a 100644 --- a/lib/net.js +++ b/lib/net.js @@ -64,19 +64,23 @@ const { onStreamRead, kUpdateTimer } = require('internal/stream_base_commons'); -const errors = require('internal/errors'); const { - ERR_INVALID_ADDRESS_FAMILY, - ERR_INVALID_ARG_TYPE, - ERR_INVALID_ARG_VALUE, - ERR_INVALID_FD_TYPE, - ERR_INVALID_IP_ADDRESS, - ERR_INVALID_OPT_VALUE, - ERR_SERVER_ALREADY_LISTEN, - ERR_SERVER_NOT_RUNNING, - ERR_SOCKET_BAD_PORT, - ERR_SOCKET_CLOSED -} = errors.codes; + codes: { + ERR_INVALID_ADDRESS_FAMILY, + ERR_INVALID_ARG_TYPE, + ERR_INVALID_ARG_VALUE, + ERR_INVALID_FD_TYPE, + ERR_INVALID_IP_ADDRESS, + ERR_INVALID_OPT_VALUE, + ERR_SERVER_ALREADY_LISTEN, + ERR_SERVER_NOT_RUNNING, + ERR_SOCKET_BAD_PORT, + ERR_SOCKET_CLOSED + }, + errnoException, + exceptionWithHostPort, + uvExceptionWithHostPort +} = require('internal/errors'); const { validateInt32, validateString } = require('internal/validators'); const kLastWriteQueueSize = Symbol('lastWriteQueueSize'); @@ -84,12 +88,6 @@ const kLastWriteQueueSize = Symbol('lastWriteQueueSize'); let cluster; let dns; -const { - errnoException, - exceptionWithHostPort, - uvExceptionWithHostPort -} = errors; - const { kTimeout, setUnrefTimeout,