Add 500 error support

This commit is contained in:
Ethanell 2020-04-26 19:31:43 +02:00
parent 6e66b84cdd
commit af378b0f50
2 changed files with 10 additions and 0 deletions

5
app.js
View file

@ -103,5 +103,10 @@ app.use(morgan("dev"))
res.status(404); res.status(404);
res.render("404", {url: req.path}); res.render("404", {url: req.path});
}) })
.use((err, req, res, next) => {
console.error(err.stack);
res.status(500);
res.render("error");
})
.listen(8080); .listen(8080);

5
views/error.pug Normal file
View file

@ -0,0 +1,5 @@
extend layout
block content
h1 500 - Internal error
p Sorry an unexpected error occurred internally