Skip to content

Commit 7be4ab1

Browse files
author
codingChewie
committed
Handling 404 Errors
1 parent 256a94f commit 7be4ab1

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

app.js

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ app.use(cookieParser())
99

1010
app.set('view engine', 'pug')
1111

12-
app.use((req, res, next) => {
13-
const err = new Error('Oh no')
14-
err.status = 500
15-
next(err)
16-
})
12+
// app.use((req, res, next) => {
13+
// const err = new Error('Oh no')
14+
// err.status = 500
15+
// next(err)
16+
// })
1717

1818
app.use((req, res, next) => {
1919
console.log(req.message)
@@ -54,6 +54,12 @@ app.post('/goodbye', (req, res) => {
5454
res.redirect('/hello')
5555
})
5656

57+
app.use((req, res, next) => {
58+
const err = new Error('Not Found')
59+
err.status = 404
60+
next(err)
61+
})
62+
5763
app.use((err, req, res, next) => {
5864
res.locals.error = err
5965
res.status(err.status)

0 commit comments

Comments
 (0)