From 3450a4c5369b857c17e06e4230589454712b6eb6 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 | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/lib/net.js b/lib/net.js index 20b0ede7b78b3b..190f40c38f78b6 100644 --- a/lib/net.js +++ b/lib/net.js @@ -64,18 +64,22 @@ const { onStreamRead, kUpdateTimer } = require('internal/stream_base_commons'); -const errors = require('internal/errors'); const { - ERR_INVALID_ADDRESS_FAMILY, - ERR_INVALID_ARG_TYPE, - 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_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'); @@ -83,12 +87,6 @@ const kLastWriteQueueSize = Symbol('lastWriteQueueSize'); let cluster; let dns; -const { - errnoException, - exceptionWithHostPort, - uvExceptionWithHostPort -} = errors; - const { kTimeout, setUnrefTimeout,