Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

adds 'url' to log context for rendering errors #687

Merged
merged 2 commits into from
Sep 18, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 2 additions & 2 deletions lib/render.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ function renderComponent(req, res, hrStart) {
options = options || {};

if (renderer instanceof Error) {
log('error', renderer);
log('error', renderer, { url: res.locals.url });
return Promise.reject(renderer);
}
// Add request route params, request query params
Expand All @@ -88,7 +88,7 @@ function renderComponent(req, res, hrStart) {
.then(cmptData => formDataForRenderer(cmptData, { _ref }, locals))
.tap(logTime(hrStart, _ref))
.then(({data, options}) => renderer.render(data, options, res))
.catch(err => log('error', err));
.catch(err => log('error', err, { url: res.locals.url }));
}

/**
Expand Down
4 changes: 2 additions & 2 deletions lib/responses.js
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ function notFound(err, res) {
*/
function serverError(err, res) {
// error is required to be logged
log('error', err.message, { stack: err.stack });
log('error', err.message, { stack: err.stack, url: res.locals.url });

const message = err.message || 'Server Error', // completely hide these messages from outside
code = 500;
Expand Down Expand Up @@ -312,7 +312,7 @@ function unauthorized(res) {
* @param {object} res
*/
function clientError(err, res) {
log('error', err.message, { stack: err.stack });
log('error', err.message, { stack: err.stack, url: res.locals.url });
Copy link
Contributor Author

Choose a reason for hiding this comment

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

TODO: Is a clientError really worthy of generating an error level log on the server side or should this be a warning?

// They know it's a 400 already, we don't need to repeat the fact that its an error.
const message = removePrefix(err.message, ':'),
code = 400;
Expand Down