From af378b0f508354b43bdabb20539887934f8564fb Mon Sep 17 00:00:00 2001 From: flifloo Date: Sun, 26 Apr 2020 19:31:43 +0200 Subject: [PATCH] Add 500 error support --- app.js | 5 +++++ views/error.pug | 5 +++++ 2 files changed, 10 insertions(+) create mode 100644 views/error.pug diff --git a/app.js b/app.js index 12259c9..5443763 100644 --- a/app.js +++ b/app.js @@ -103,5 +103,10 @@ app.use(morgan("dev")) res.status(404); res.render("404", {url: req.path}); }) + .use((err, req, res, next) => { + console.error(err.stack); + res.status(500); + res.render("error"); + }) .listen(8080); diff --git a/views/error.pug b/views/error.pug new file mode 100644 index 0000000..d00ecb8 --- /dev/null +++ b/views/error.pug @@ -0,0 +1,5 @@ +extend layout +block content + h1 500 - Internal error + p Sorry an unexpected error occurred internally +