From ba463c8755b573f07e446747c0b10d7325b2f4c0 Mon Sep 17 00:00:00 2001 From: Stephen Zhou <38493346+hyoban@users.noreply.github.com> Date: Fri, 8 Nov 2024 15:33:22 +0800 Subject: [PATCH] catch detail error --- lib/routes/csdn/blog.ts | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/lib/routes/csdn/blog.ts b/lib/routes/csdn/blog.ts index a2636b5ad3120e..c8a8d84ccd391d 100644 --- a/lib/routes/csdn/blog.ts +++ b/lib/routes/csdn/blog.ts @@ -39,19 +39,23 @@ async function handler(ctx) { const items = await Promise.all( feed.items.map((item) => cache.tryGet(item.link, async () => { - const response = await got({ - method: 'get', - url: item.link, - }); + try { + const response = await got({ + method: 'get', + url: item.link, + }); - const $ = load(response.data); + const $ = load(response.data); - const description = $('#content_views').html(); + const description = $('#content_views').html(); - return { - ...item, - description, - }; + return { + ...item, + description, + }; + } catch { + return item; + } }) ) );