{"record":{"id":"612442b34c0b0e71","repo":"DIYgod/RSSHub","slug":"bad-category-see-a-href-https-docs-rsshub-app","errorCode":null,"errorMessage":"Bad category. See <a href=\"https://docs.rsshub.app/routes/government#bei-jing-shi-wei-sheng-jian-kang-wei-yuan-hui\">docs</a>","messagePattern":"Bad category\\. See <a href=\"https://docs\\.rsshub\\.app/routes/government#bei-jing-shi-wei-sheng-jian-kang-wei-yuan-hui\">docs</a>","errorType":"exception","errorClass":null,"httpStatus":503,"severity":"warning","filePath":"lib/routes-deprecated/gov/beijing/mhc.js","lineNumber":29,"sourceCode":"    },\n    jcdt: {\n        link: '/xwzx_20031/jcdt/',\n        title: '基层动态',\n    },\n    mtjj: {\n        link: '/xwzx_20031/mtjj/',\n        title: '媒体聚焦',\n    },\n    rdxws: {\n        link: '/xwzx_20031/rdxws/',\n        title: '热点新闻',\n    },\n};\n\nmodule.exports = async (ctx) => {\n    const cfg = config[ctx.params.caty];\n    if (!cfg) {\n        throw new Error('Bad category. See <a href=\"https://docs.rsshub.app/routes/government#bei-jing-shi-wei-sheng-jian-kang-wei-yuan-hui\">docs</a>');\n    }\n\n    const current_url = url.resolve(root_url, cfg.link);\n    const response = await got({\n        method: 'get',\n        url: current_url,\n    });\n    const $ = cheerio.load(response.data);\n    const list = $('div.weinei_left_con div.weinei_left_con_line')\n        .slice(0, 10)\n        .map((_, item) => {\n            item = $(item);\n            const a = item.find('a[title]');\n            return {\n                title: a.text(),\n                link: url.resolve(current_url, a.attr('href')),\n                pubDate: new Date(item.find('div.weinei_left_con_line_date').text() + ' GMT+8').toUTCString(),\n            };","sourceCodeStart":11,"sourceCodeEnd":47,"githubUrl":"https://github.com/DIYgod/RSSHub/blob/bed535e0879dc71c5aff6f1e7bd1ac21ede40115/lib/routes-deprecated/gov/beijing/mhc.js#L11-L47","documentation":"Thrown by the Beijing Municipal Health Commission route (deprecated) when the requested category key is not present in the route's static config map. The handler indexes config with ctx.params.caty and, on a miss, throws a plain Error whose message links to the route's documentation anchor. It is a parameter-validation guard that runs before any network request.","triggerScenarios":"A GET to the RSSHub route with a :caty path segment whose value is not a key of the config object (e.g. /gov/beijing/mhc/<unknown>). The lookup config[ctx.params.caty] returns undefined and the throw fires.","commonSituations":"Typo in the category slug, copying a category from an outdated doc/README, or hitting the route after the source site reorganized sections and the route config was pruned. Deprecated routes under lib/routes-deprecated often have stale slugs.","solutions":["Open the docs anchor in the error message and copy a documented category slug exactly (e.g. mtjj, rdxws).","Inspect the config object at the top of lib/routes-deprecated/gov/beijing/mhc.js to list the currently accepted keys.","Migrate off the deprecated route; if no replacement exists, open an issue against RSSHub rather than guessing slugs."],"exampleFix":"// before\nGET /gov/beijing/mhc/mtjjj   // typo\n// after\nGET /gov/beijing/mhc/mtjj      // 媒体聚焦","handlingStrategy":"validation","validationCode":"const VALID = ['mtjj', 'rdxws' /* see config in lib/routes-deprecated/gov/beijing/mhc.js */];\nconst caty = ctx.params.caty;\nif (!VALID.includes(caty)) {\n  // surface your own 400 instead of relying on the route's generic Error\n  throw new Error(`Invalid caty '${caty}'. Valid: ${VALID.join(', ')}`);\n}","typeGuard":"const isCaty = (v: string): v is 'mtjj' | 'rdxws' => ['mtjj', 'rdxws'].includes(v);","tryCatchPattern":"try { await rsshub('/gov/beijing/mhc/' + caty); }\ncatch (e) {\n  if (/Bad category/.test(e.message)) { /* prompt user for a valid slug */ }\n  else throw e;\n}","preventionTips":["Source the slug list from the route's config object, not from memory.","Treat deprecated routes as unstable — pin or migrate."],"tags":["rsshub","parameter-validation","deprecated-route","government"],"backgroundTag":null,"analyzedSha":"bed535e0879dc71c5aff6f1e7bd1ac21ede40115","analyzedAt":"2026-08-12T19:29:35.364Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}