Skip to content

Commit

Permalink
Add error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
joelanman committed Jul 19, 2018
1 parent 6179d56 commit b25c933
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,19 @@ app.post(/^\/([^.]+)$/, function (req, res) {
res.redirect('/' + req.params[0])
})

// catch 404 and forward to error handler
app.use(function (req, res, next) {
var err = new Error('Page not found')
err.status = 404
next(err)
})

// display error
app.use(function (err, req, res, next) {
res.status(err.status || 500)
res.send(err.message)
})

console.log('\nGOV.UK Prototype Kit v' + releaseVersion)
console.log('\nNOTICE: the kit is for building prototypes, do not use it for production services.')

Expand Down

0 comments on commit b25c933

Please sign in to comment.