Skip to content

Commit

Permalink
feat(logging): improve error message & add link to Node errors page. (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
cloudmu authored and chimurai committed Sep 1, 2016
1 parent 28030c5 commit 7d1865c
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lib/index.js
Expand Up @@ -128,9 +128,10 @@ function HttpProxyMiddleware(context, opts) {
}

function logError(err, req, res) {
var hostname = (req.hostname || req.host) || (req.headers && req.headers.host); // (node0.10 || node 4/5) || (websocket)
var targetUri = (proxyOptions.target.host || proxyOptions.target) + req.url;
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 errReference = 'https://nodejs.org/api/errors.html#errors_common_system_errors'; // link to Node Common Systems Errors page

logger.error('[HPM] PROXY ERROR: %s. %s -> %s', err.code, hostname, targetUri);
logger.error('[HPM] Error occurred while trying to proxy request %s from %s to %s (%s) (%s)', req.url, hostname, target, err.code, errReference);
}
};

0 comments on commit 7d1865c

Please sign in to comment.