From a42d44f834e7f70d1428e5f32bba3dd73e1db6aa Mon Sep 17 00:00:00 2001 From: PangBo <51732678+pangbo13@users.noreply.github.com> Date: Wed, 14 Aug 2024 23:31:13 +0800 Subject: [PATCH] fix(route): handle error when fetching sjtu/jwc article (#16448) --- lib/routes/sjtu/jwc.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/routes/sjtu/jwc.ts b/lib/routes/sjtu/jwc.ts index 0b726132a88769..3930f8f6a29780 100644 --- a/lib/routes/sjtu/jwc.ts +++ b/lib/routes/sjtu/jwc.ts @@ -7,7 +7,10 @@ import { parseDate } from '@/utils/parse-date'; const urlRoot = 'https://jwc.sjtu.edu.cn/xwtg'; async function getFullArticle(link) { - const response = await got(link); + const response = await got(link).catch(() => null); + if (!response) { + return null; + } const $ = load(response.body); const content = $('.content-con'); if (content.length === 0) {