Skip to content

Commit

Permalink
BAU Log error message when rendering error page
Browse files Browse the repository at this point in the history
If we catch an error and render the error page, we do not currently
log the error message. The `error` always evaluates as an empty
JSON object when we attempt to log it so it is not included. Instead,
log the error message.
  • Loading branch information
stephencdaly committed Feb 20, 2024
1 parent bcef229 commit 688b306
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion app/utils/response-router.js
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ function logErrorPageShown (page, reason, loggingFields, error) {
logger.info('Rendering error response', {
page,
reason,
error,
error: (error && error.message) || error,
...loggingFields
})
}
Expand Down
4 changes: 2 additions & 2 deletions test/utils/response-router.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ describe('rendering behaviour', () => {
})

it('should render error response', () => {
responseRouter.errorResponse(request, response, 'A reason', { returnUrl: 'http://example.com' }, 'err')
responseRouter.errorResponse(request, response, 'A reason', { returnUrl: 'http://example.com' }, new Error('err'))
expect(render.lastCall.args).to.deep.equal(['error', {
returnUrl: 'http://example.com',
viewName: 'ERROR',
Expand All @@ -136,7 +136,7 @@ describe('rendering behaviour', () => {
})

it('should render system error response', () => {
responseRouter.systemErrorResponse(request, response, 'A reason', { returnUrl: 'http://example.com' }, 'err')
responseRouter.systemErrorResponse(request, response, 'A reason', { returnUrl: 'http://example.com' }, new Error('err'))
expect(render.lastCall.args).to.deep.equal(['errors/system-error', {
returnUrl: 'http://example.com',
viewName: 'SYSTEM_ERROR'
Expand Down

0 comments on commit 688b306

Please sign in to comment.