From ac6021a57990d17b4a218ace0fad50130fd1bfb2 Mon Sep 17 00:00:00 2001 From: Raccoon Date: Sun, 17 May 2020 03:25:57 +0800 Subject: [PATCH] fix: returning 500 when getStatus failed Signed-off-by: Raccoon --- lib/status/index.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/status/index.js b/lib/status/index.js index 56c92ec0..2f5366d6 100644 --- a/lib/status/index.js +++ b/lib/status/index.js @@ -4,14 +4,19 @@ const realtime = require('../realtime/realtime') const config = require('../config') exports.getStatus = async (req, res) => { - const data = await realtime.getStatus() - res.set({ 'Cache-Control': 'private', // only cache by client 'X-Robots-Tag': 'noindex, nofollow', // prevent crawling 'Content-Type': 'application/json' }) - res.send(data) + + try { + const data = await realtime.getStatus() + res.send(data) + } catch (e) { + console.error(e) + res.status(500).send(e.toString()) + } } exports.getMetrics = async (req, res) => {