Skip to content

Commit 8be5919

Browse files
committed
feat(logging): remove errno dependency & add link to Node errors page.
1 parent 9614dd0 commit 8be5919

File tree

2 files changed

+5
-11
lines changed

2 files changed

+5
-11
lines changed

lib/index.js

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
var _ = require('lodash');
22
var httpProxy = require('http-proxy');
3-
var errno = require('errno');
43
var configFactory = require('./config-factory');
54
var handlers = require('./handlers');
65
var contextMatcher = require('./context-matcher');
@@ -129,14 +128,10 @@ function HttpProxyMiddleware(context, opts) {
129128
}
130129

131130
function logError(err, req, res) {
132-
var hostname = (req.headers && req.headers.host) || (req.hostname || req.host); // (websocket) || (node0.10 || node 4/5)
131+
var hostname = (req.headers && req.headers.host) || (req.hostname || req.host); // (websocket) || (node0.10 || node 4/5)
133132
var target = proxyOptions.target.host || proxyOptions.target;
134-
var description = errno.code[err.code] && errno.code[err.code].description; // description for the error code
135-
136-
if (description) {
137-
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);
138-
} else {
139-
logger.error('[HPM] Error (ErrorCode=%s) occurred while trying to proxy request %s from %s to %s', err.code, req.url, hostname, target);
140-
}
133+
var errReference = 'https://nodejs.org/api/errors.html#errors_common_system_errors'; // link to Node Common Systems Errors page
134+
135+
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);
141136
}
142137
};

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@
5151
"http-proxy": "^1.14.0",
5252
"is-glob": "^2.0.1",
5353
"lodash": "^4.14.2",
54-
"micromatch": "^2.3.11",
55-
"errno": "^0.1.4"
54+
"micromatch": "^2.3.11"
5655
}
5756
}

0 commit comments

Comments
 (0)