{"record":{"id":"d2652dfa30db8ebc","repo":"DIYgod/RSSHub","slug":"title","errorCode":null,"errorMessage":"未能获取热榜数据: ${title}","messagePattern":"未能获取热榜数据: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"lib/routes/jandan/utils.ts","lineNumber":48,"sourceCode":"export const handleTopSection = async (rootUrl: string, type: string): Promise<{ title: string; items: DataItem[] }> => {\n    const apiUrl = `${rootUrl}/api/top/${type}`;\n    const response = await ofetch(apiUrl);\n\n    let title = '热榜';\n    switch (type) {\n        case 'pic3days':\n            title += ' - 3天内无聊图';\n            break;\n        case 'pic7days':\n            title += ' - 7天内无聊图';\n            break;\n        default:\n            title += ' - 4小时热门';\n            break;\n    }\n\n    if (response.code !== 0) {\n        throw new Error(`未能获取热榜数据: ${title}`);\n    }\n\n    const items = response.data.map((item) => {\n        const content = item.content.replaceAll(/img src=\"(.*?)\"/g, (match, src) => match.replace(src, () => src.replace(/^https?:\\/\\/(\\w+)\\.moyu\\.im/, 'https://$1.sinaimg.cn')));\n\n        return {\n            author: item.author,\n            title: `${item.author}: ${sanitizeHtml(content, { allowedTags: [], allowedAttributes: {} })}`,\n            description: content,\n            pubDate: parseDate(item.date_gmt),\n            link: `${rootUrl}/t/${item.id}`,\n        } as DataItem;\n    });\n\n    return { title, items };\n};\n\n/**","sourceCodeStart":30,"sourceCodeEnd":66,"githubUrl":"https://github.com/DIYgod/RSSHub/blob/bed535e0879dc71c5aff6f1e7bd1ac21ede40115/lib/routes/jandan/utils.ts#L30-L66","documentation":"Thrown by 煎蛋 (jandan) utils when the hot-list API response's `code` field is not `0`. The route interprets `code === 0` as success (standard Chinese-API convention); any other code means the upstream rejected/failed the request. The message includes the resolved `title` (the ranking variant being fetched) for context.","triggerScenarios":"Request to a jandan hot-list route (e.g. `/jandan/pic4hours`, `pic3days`, `pic7days`, etc.) where the upstream moyu.im / jandan API returns `response.code !== 0` — server-side error, invalid ranking type, or upstream maintenance.","commonSituations":"Upstream API temporarily returns an error code; the ranking-type param was accepted by the route's switch but rejected by the API; upstream IP-blocked the RSSHub server; API schema/version drift.","solutions":["Retry after a short delay — transient upstream errors often clear.","Clear any cached failed response so the route re-fetches (the response is cached via `cache.tryGet`).","Verify the upstream API directly (inspect the jandan/moyu endpoint) to see the returned code/message and adjust the route if the API changed.","If the server IP is blocked, use a proxy."],"exampleFix":"// before: upstream returns { code: -1, msg: 'error' } -> throw\n// after: clear cache + retry, or surface the upstream msg for diagnosis\nif (response.code !== 0) {\n    throw new Error(`未能获取热榜数据 (${response.code}): ${response.msg ?? ''} [${title}]`);\n}","handlingStrategy":"validation","validationCode":"if (response.code !== 0) {\n  throw new Error(`未能获取热榜数据 (${response.code}): ${response.msg ?? 'upstream error'} [${title}]`);\n}","typeGuard":"const isOkCode = (r: any): r is {code:0; data:any[]} => r && r.code === 0 && Array.isArray(r.data);","tryCatchPattern":"try {\n  const response = await got(apiUrl);\n  if (response.code !== 0) throw new Error(`jandan upstream code ${response.code}`);\n} catch (e) { /* one retry, then surface with context */ throw e; }","preventionTips":["Cache the successful response (route already uses cache.tryGet) and avoid hammering upstream.\nSurface the upstream code/msg in the error for diagnosis.\nRetry once on transient non-zero codes."],"tags":["jandan","upstream-api","error-code","cache"],"backgroundTag":null,"analyzedSha":"bed535e0879dc71c5aff6f1e7bd1ac21ede40115","analyzedAt":"2026-08-12T19:29:35.364Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}