Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Do not log as errors below a 500 response #1256

Merged
merged 6 commits into from
Apr 22, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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