Skip to content

Commit

Permalink
Properly serialize errors as JSON
Browse files Browse the repository at this point in the history
  • Loading branch information
Jalle19 committed Feb 8, 2024
1 parent 8584d7a commit 4b7ec13
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion app/http.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -108,5 +108,8 @@ const handleError = (e, res, statusCode = undefined) => {
logger.error(`An exception occurred: ${e.name}: ${e.message}`, e.stack)
// Use HTTP 500 if no status code has been set
res.status(statusCode ?? 500)
res.json(e)
res.json({
error: e.name,
message: e.message,
})
}

0 comments on commit 4b7ec13

Please sign in to comment.