aboutsummaryrefslogtreecommitdiff
path: root/src/server
diff options
context:
space:
mode:
Diffstat (limited to 'src/server')
-rw-r--r--src/server/app.js14
-rw-r--r--src/server/routes/getSchedule.js4
2 files changed, 5 insertions, 13 deletions
diff --git a/src/server/app.js b/src/server/app.js
index 7e8d9e9..bd87162 100644
--- a/src/server/app.js
+++ b/src/server/app.js
@@ -54,21 +54,9 @@ app.use((req, res, next) => {
next(err);
});
-function extractStatusCodeFromError(error) {
- if (error.status) {
- return error.status;
- } else if (error.response) {
- return error.response.status;
- }
-
- return null;
-}
-
// error handler
app.use((error, req, res, next) => {
- const errorCode = extractStatusCodeFromError(error) || 500;
- res.status(errorCode);
-
+ res.status(error.status || 500);
res.render('error', {
message: error.message,
error,
diff --git a/src/server/routes/getSchedule.js b/src/server/routes/getSchedule.js
index f1120b7..04df28a 100644
--- a/src/server/routes/getSchedule.js
+++ b/src/server/routes/getSchedule.js
@@ -69,6 +69,10 @@ router.get('/:type/:value', (req, res, next) => {
res.status(response.status).end(response.data);
})
.catch((err) => {
+ if (err.response) {
+ // eslint-disable-next-line no-param-reassign
+ err.status = err.response.status;
+ }
next(err);
});
});