From 7b61bcd54114ed66f12ffd638d7d3d363546fd08 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miroslav=20Bajto=C5=A1?= Date: Mon, 12 Oct 2020 09:56:56 +0200 Subject: [PATCH] [SEMVER-MAJOR] Reword log messages for clarity MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Before this commit, we logged messages saying "unhandled error". This was often creating confusion for our users, it seems like the error was not handled at all, when in fact it was caught by the configured error handler and converted into a proper HTTP error response. In this commit, I am changing the messaging to use "request failed" instead. While this change is not affecting application developers, it may break tooling processing logs if the tool relies on a specific format of error messages. To be safe, I am labelling this change as breaking. Signed-off-by: Miroslav Bajtoš --- lib/logger.js | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/logger.js b/lib/logger.js index 4ce4095..4dce912 100644 --- a/lib/logger.js +++ b/lib/logger.js @@ -10,12 +10,12 @@ const g = require('strong-globalize')(); module.exports = function logToConsole(req, err) { if (!Array.isArray(err)) { - g.error('Unhandled error for request %s %s: %s', + g.error('Request %s %s failed: %s', req.method, req.url, err.stack || err); return; } - const errMsg = g.f('Unhandled array of errors for request %s %s\n', + const errMsg = g.f('Request %s %s failed with multiple errors:\n', req.method, req.url); const errors = err.map(formatError).join('\n'); console.error(errMsg, errors); diff --git a/package.json b/package.json index 9a7cde0..3b90d28 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "strong-error-handler", "description": "Error handler for use in development and production environments.", "license": "MIT", - "version": "3.5.0", + "version": "4.0.0-1", "engines": { "node": ">=10" },