Skip to content
Merged
Show file tree
Hide file tree
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
16 changes: 6 additions & 10 deletions designer/server/src/plugins/errorPage.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import Boom from '@hapi/boom'
import {
type Request,
type ResponseToolkit,
Expand All @@ -24,11 +25,10 @@ export default {
server.ext('onPreResponse', (request: Request, h: ResponseToolkit) => {
const response = request.response

if ('isBoom' in response && response.isBoom) {
if (Boom.isBoom(response)) {
// An error was raised during
// processing the request
const statusCode = response.output.statusCode
const errorMessage = errorCodes.get(statusCode)

if (statusCode === StatusCodes.NOT_FOUND.valueOf()) {
request.logger.info(
Expand All @@ -40,21 +40,17 @@ export default {
.code(statusCode)
}

const logLevel =
statusCode === StatusCodes.NOT_FOUND.valueOf() ? 'info' : 'error'
request.logger[logLevel](
response,
statusCode === StatusCodes.NOT_FOUND.valueOf()
? 'Resource not found'
: 'Unhandled error found'
)
Comment on lines -43 to -50
Copy link
Contributor

Choose a reason for hiding this comment

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

good spot, wonder why we never spotted this unreachable code before!

request.logger.error(response, 'Unhandled error found')

const errorMessage = errorCodes.get(statusCode)

if (errorMessage) {
return h
.view(statusCode.toString(), errorViewModel(errorMessage))
.code(statusCode)
}
}

return h.continue
})
}
Expand Down
Loading
Loading