handle error with try catch

This commit is contained in:
DIYgod 2018-04-12 11:49:55 +08:00
parent 59c7a65d69
commit c2053608cf
No known key found for this signature in database
GPG Key ID: EC0B76A252D3EF67
1 changed files with 10 additions and 4 deletions

View File

@ -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('');
}
}
});
};