From c2053608cffbd42935d13c315a877f41fe3e4bdd Mon Sep 17 00:00:00 2001 From: DIYgod Date: Thu, 12 Apr 2018 11:49:55 +0800 Subject: [PATCH] handle error with try catch --- routes/base.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/routes/base.js b/routes/base.js index 64b73c63a..0b08e491d 100644 --- a/routes/base.js +++ b/routes/base.js @@ -10,10 +10,16 @@ module.exports = (options) => { options.res.send(reply); } else { - options.getHTML((html) => { - redis.set(options.req.url, html); - options.res.send(html); - }); + try { + options.getHTML((html) => { + redis.set(options.req.url, html); + options.res.send(html); + }); + } + catch (e) { + redis.set(options.req.url, ''); + options.res.send(''); + } } }); }; \ No newline at end of file