{"record":{"id":"ca3d97b5934414df","repo":"DIYgod/RSSHub","slug":"response-error-message","errorCode":null,"errorMessage":"response.error.message","messagePattern":"response\\.error\\.message","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"lib/routes/gamer/ani/anime.ts","lineNumber":40,"sourceCode":"            target: '/anime/:sn',\n        },\n    ],\n    name: '動畫瘋 - 動畫',\n    maintainers: ['maple3142', 'pseudoyu'],\n    handler,\n};\n\nasync function handler(ctx) {\n    const { sn } = ctx.req.param();\n\n    const { data: response } = await got('https://api.gamer.com.tw/mobile_app/anime/v3/video.php', {\n        searchParams: {\n            sn,\n        },\n    });\n\n    if (response.error) {\n        throw new Error(response.error.message);\n    }\n\n    const anime = response.data.anime;\n    const title = anime.title.replaceAll(/\\[\\d+\\]$/g, '').trim();\n\n    const items = anime.volumes[0]\n        .map((item) => ({\n            title: `${title} 第 ${item.volume} 集`,\n            description: `<img src=\"${item.cover}\">`,\n            link: `https://ani.gamer.com.tw/animeVideo.php?sn=${item.video_sn}`,\n        }))\n        .toReversed();\n\n    return {\n        title,\n        link: `https://ani.gamer.com.tw/animeRef.php?sn=${anime.anime_sn}`,\n        description: anime.content?.trim(),\n        item: items,","sourceCodeStart":22,"sourceCodeEnd":58,"githubUrl":"https://github.com/DIYgod/RSSHub/blob/bed535e0879dc71c5aff6f1e7bd1ac21ede40115/lib/routes/gamer/ani/anime.ts#L22-L58","documentation":"The gamer.com.tw anime API (video.php v3) returns a top-level error object when it cannot fulfill the request — for example an invalid or removed anime serial number (sn). The route checks for response.error and re-throws the API's own error.message verbatim, so the visible text depends entirely on what the API returns.","triggerScenarios":"Requesting an anime video.php resource with an sn that does not exist, has been removed/geoblocked, or the API rejects due to missing/invalid client headers. The API still returns HTTP 200 but with an error body.","commonSituations":"Users copying an outdated sn from an old link; anime being taken down regionally; gamer.com.tw tightening API access requiring specific headers or cookies; the sn being a non-numeric value.","solutions":["Open https://ani.gamer.com.tw, find the anime, and copy the current sn from the URL.","Inspect the full response.error object to see if there is a code/hint (geoblock, removed, auth).","Ensure required request headers ( referer, client cookies) are sent with the got call if gamer.com.tw enforces them.","Validate sn is numeric before calling the API."],"exampleFix":"// before\nif (response.error) {\n    throw new Error(response.error.message);\n}\n\n// after\nif (response.error) {\n    const snNum = Number(sn);\n    if (!Number.isFinite(snNum)) {\n        throw new InvalidParameterError(`sn must be numeric, got: ${sn}`);\n    }\n    throw new Error(`gamer.com.tw anime API error for sn=${sn}: ${response.error.message}`);\n}","handlingStrategy":"validation","validationCode":"if (!/^\\d+$/.test(sn)) {\n  throw new InvalidParameterError('sn must be numeric');\n}","typeGuard":"const isNumericSn = (v: string): v is string => /^\\d+$/.test(v);","tryCatchPattern":null,"preventionTips":["Validate sn is numeric before the API call.\nInclude the sn in the thrown message for easier triage.\nSend any required referer/cookie headers gamer.com.tw expects."],"tags":["api","validation","user-input"],"backgroundTag":null,"analyzedSha":"bed535e0879dc71c5aff6f1e7bd1ac21ede40115","analyzedAt":"2026-08-12T19:29:35.364Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}