Skip to content

Commit 7d1865c

Browse files
cloudmuchimurai
authored andcommitted
feat(logging): improve error message & add link to Node errors page. (chimurai#106)
1 parent 28030c5 commit 7d1865c

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

lib/index.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,10 @@ function HttpProxyMiddleware(context, opts) {
128128
}
129129

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

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

0 commit comments

Comments
 (0)