From e98d589683ce84757f72794e49cb35b69e3688e3 Mon Sep 17 00:00:00 2001 From: Tom Russell Date: Sun, 30 Sep 2018 21:53:41 +0100 Subject: [PATCH] Catch-all server-side HTML route errors --- app/src/server.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/app/src/server.js b/app/src/server.js index 9bce6118..3fe8b364 100644 --- a/app/src/server.js +++ b/app/src/server.js @@ -86,7 +86,13 @@ function frontendRoute(req, res) { data.user = user; data.building = building; renderHTML(context, data, req, res) - }) + }).catch(error => { + console.error(error); + data.user = undefined; + data.building = undefined; + contex.status = 500; + renderHTML(context, data, req, res); + }); } function renderHTML(context, data, req, res){ @@ -177,6 +183,7 @@ server.route('/building/:building_id.json') res.status(404).send({error:'Not Found'}) } }).catch(function(error){ + console.error(error); res.send({error:'Database error'}) }) })