From ab485dd55c3d4a39242b8233003e89e2f2656836 Mon Sep 17 00:00:00 2001 From: Sorin Davidoi Date: Sun, 25 Nov 2018 17:48:10 +0000 Subject: [PATCH] fix(log): Handle case when error code is missing (#303) # Before ``` HPM] Error occurred while trying to proxy request from to (undefined) (https://nodejs.org/api/errors.html#errors_common_system_errors) ``` # After ``` [HPM] Error occurred while trying to proxy request from to (Error: Hostname/IP doesn't match certificate's altnames: "Host: . is not in the cert's altnames: DNS:, DNS:") (https://nodejs.org/api/errors.html#errors_common_system_errors) ``` --- lib/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/index.js b/lib/index.js index 88bc3ef1..fa384756 100644 --- a/lib/index.js +++ b/lib/index.js @@ -147,6 +147,6 @@ function HttpProxyMiddleware (context, opts) { var errorMessage = '[HPM] Error occurred while trying to proxy request %s from %s to %s (%s) (%s)' var errReference = 'https://nodejs.org/api/errors.html#errors_common_system_errors' // link to Node Common Systems Errors page - logger.error(errorMessage, req.url, hostname, target, err.code, errReference) + logger.error(errorMessage, req.url, hostname, target, err.code || err, errReference) } }