diff --git a/lib/middleware/parameter.js b/lib/middleware/parameter.js index 3a2117a936..27e87d62b9 100644 --- a/lib/middleware/parameter.js +++ b/lib/middleware/parameter.js @@ -19,16 +19,21 @@ module.exports = async (ctx, next) => { const tasks = ctx.state.data.item.map(async (item) => { const { link, author, description } = item; const parsed_result = await ctx.cache.tryGet(`mercury-cache-${link}`, async () => { - const res = await got(link); - const $ = cheerio.load(res.data); - const result = await mercury_parser.parse(link, { - html: $.html(), - }); - return result; + // if parser failed, return default description and not report error + try { + const res = await got(link); + const $ = cheerio.load(res.data); + const result = await mercury_parser.parse(link, { + html: $.html(), + }); + return result; + } catch (e) { + // no-empty + } }); - item.author = author || parsed_result.author; - item.description = parsed_result.content || description; + item.author = author || (parsed_result ? parsed_result.author : ''); + item.description = parsed_result ? parsed_result.content : description; }); await Promise.all(tasks); }