From 8be5919e5b6c9cd3d846a591c7530315e023632d Mon Sep 17 00:00:00 2001 From: yunjun Date: Tue, 30 Aug 2016 19:27:44 -0400 Subject: [PATCH] feat(logging): remove errno dependency & add link to Node errors page. --- lib/index.js | 13 ++++--------- package.json | 3 +-- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/lib/index.js b/lib/index.js index 7f3a1f38..0f9e3e2e 100644 --- a/lib/index.js +++ b/lib/index.js @@ -1,6 +1,5 @@ var _ = require('lodash'); var httpProxy = require('http-proxy'); -var errno = require('errno'); var configFactory = require('./config-factory'); var handlers = require('./handlers'); var contextMatcher = require('./context-matcher'); @@ -129,14 +128,10 @@ function HttpProxyMiddleware(context, opts) { } function logError(err, req, res) { - var hostname = (req.headers && req.headers.host) || (req.hostname || req.host); // (websocket) || (node0.10 || node 4/5) + var hostname = (req.headers && req.headers.host) || (req.hostname || req.host); // (websocket) || (node0.10 || node 4/5) var target = proxyOptions.target.host || proxyOptions.target; - var description = errno.code[err.code] && errno.code[err.code].description; // description for the error code - - if (description) { - logger.error('[HPM] Error \'%s\' (ErrorCode=%s) occurred while trying to proxy request %s from %s to %s', description, err.code, req.url, hostname, target); - } else { - logger.error('[HPM] Error (ErrorCode=%s) occurred while trying to proxy request %s from %s to %s', err.code, req.url, hostname, target); - } + var errReference = 'https://nodejs.org/api/errors.html#errors_common_system_errors'; // link to Node Common Systems Errors page + + logger.error('[HPM] Error occurred while trying to proxy request %s from %s to %s (%s) \n(%s)', req.url, hostname, target, err.code, errReference); } }; diff --git a/package.json b/package.json index 50bbd4b1..449e40fb 100644 --- a/package.json +++ b/package.json @@ -51,7 +51,6 @@ "http-proxy": "^1.14.0", "is-glob": "^2.0.1", "lodash": "^4.14.2", - "micromatch": "^2.3.11", - "errno": "^0.1.4" + "micromatch": "^2.3.11" } }