Skip to content

Commit

Permalink
Ajout d'une protection supplémentaire afin de ne pas planter le serveur
Browse files Browse the repository at this point in the history
  • Loading branch information
ggrossetie committed Oct 4, 2022
1 parent 13bc751 commit 42ead4d
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion export/src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,12 @@ app.use(function errorHandler (error, req, res, next) {
if (error.name === 'FindByIdNotFoundError') {
return res.status(404).send({ error: { message: error.message } })
}

logger.error({ cause: error, typeOf: (typeof error), causeString: String(error) }, 'Something went wrong!')
if (res.headersSent) {
// no-op
logger.warn('Headers already sent, aborting.')
return res.status(500)
}
const message = error.message
const stack = error.stack
const type = error.constructor && error.constructor.name
Expand Down

0 comments on commit 42ead4d

Please sign in to comment.