Skip to content

Commit

Permalink
feat(logging): remove errno dependency & add link to Node errors page.
Browse files Browse the repository at this point in the history
  • Loading branch information
cloudmu committed Aug 30, 2016
1 parent 9614dd0 commit 8be5919
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 11 deletions.
13 changes: 4 additions & 9 deletions lib/index.js
Original file line number Diff line number Diff line change
@@ -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');
Expand Down Expand Up @@ -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);
}
};
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}

0 comments on commit 8be5919

Please sign in to comment.