Skip to content
This repository has been archived by the owner on Jun 19, 2023. It is now read-only.

Don't log 4XX errors as error-level in our logs for right now #370

Merged
merged 3 commits into from Sep 22, 2017

Conversation

h-will-h
Copy link

No description provided.

});

// Only want to warn about 400s for now (maybe forever?)
if (statusCode < 500) {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Truthfully, I'm not sure if new relic picks these up, but I think better to err on the side of caution.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah i'm guessing it watches stderr

const log = ((statusCode >= 400 && logger.error) ||
(statusCode >= 300 && logger.warn) ||
const log = ((statusCode >= 500 && logger.error) ||
(statusCode >= 400 && logger.warn) ||
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm betting on this definitely making a difference.

if (response.statusCode >= 400) {
// Don't throw an error for 400s for now (maybe forever?)
return formatApiError({ message: response.statusMessage }, value);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this has the same effect of the previous implementation - formatApiError expects an Error instance and will take the message prop from it without throwing.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I did this first and it I don't think it's helpful. Removed.

if (statusCode < 500) {
console.warn(errorMessageString);
} else {
console.error(errorMessageString);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

trivially DRYer alternative

const logError = statusCode < 500 ? console.warn : console.error;
logError(errorMessageString);

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@h-will-h
Copy link
Author

OK, comments addressed.

@h-will-h h-will-h merged commit 08eea52 into master Sep 22, 2017
@chenrui333 chenrui333 deleted the 400s_are_not_errors branch September 16, 2019 22:36
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants