Skip to content

Commit

Permalink
Updated README sample code.
Browse files Browse the repository at this point in the history
  • Loading branch information
RobertoMachorro authored Sep 13, 2024
1 parent 6605e26 commit 546eb78
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,20 @@ webapp.run({
})
},
errorMiddleware: (error, request, response, _) => {
response.status(500).json({
code: 500,
message: error
})
if (request.xhr) {
response.status(500).json({
code: 500,
message: (error.message)? error.message : error,
stack: request.app.get('env') === 'development' ? error.stack : ''
})
} else {
response.render('error', {
pageTitle: 'Oops!',
status: 500,
message: (error.message)? error.message : error,
stack: request.app.get('env') === 'development' ? error.stack : '',
})
}
},
})
```
Expand Down

0 comments on commit 546eb78

Please sign in to comment.