Skip to content

Commit

Permalink
fix: Do not log as errors below a 500 response (#1256)
Browse files Browse the repository at this point in the history
  • Loading branch information
garrypolley authored and daffl committed Apr 22, 2019
1 parent 3f0b1c3 commit 33fd0e4
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions packages/errors/lib/error-handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,16 @@ module.exports = function (options = {}) {
}

return function (error, req, res, next) {
// Set the error code for HTTP processing semantics
error.code = !isNaN(parseInt(error.code, 10)) ? parseInt(error.code, 10) : 500;

// Log the error if it didn't come from a service method call
if (options.logger && typeof options.logger.error === 'function' && !res.hook) {
options.logger.error(error);
if (error.code >= 500) {
options.logger.error(error);
} else {
options.logger.info(error);
}
}

if (error.type !== 'FeathersError') {
Expand All @@ -39,7 +46,6 @@ module.exports = function (options = {}) {
}
}

error.code = !isNaN(parseInt(error.code, 10)) ? parseInt(error.code, 10) : 500;
const formatter = {};

// If the developer passed a custom function for ALL html errors
Expand Down

0 comments on commit 33fd0e4

Please sign in to comment.