{"record":{"id":"c1f035c5f1ff1695","repo":"DIYgod/RSSHub","slug":"bad-type","errorCode":null,"errorMessage":"Bad type","messagePattern":"Bad type","errorType":"exception","errorClass":null,"httpStatus":503,"severity":"warning","filePath":"lib/routes-deprecated/emi-nitta/home.js","lineNumber":30,"sourceCode":"    },\n\n    news: {\n        link: '/contents/news',\n        title: 'Emi Nitta - News',\n        description: 'News of Emi Nitta',\n    },\n};\n\nconst get_date = (o) => {\n    const match = /(\\d{4}\\.\\d+\\.\\d+)/.exec(o.text().trim());\n    const date = match ? match[1] : o.attr('datetime');\n    return new Date(date + ' GMT+9').toUTCString();\n};\n\nmodule.exports = async (ctx) => {\n    const cfg = config[ctx.params.type];\n    if (!cfg) {\n        throw new Error('Bad type');\n    }\n\n    const response = await got({\n        method: 'get',\n        url: url.resolve(root_url, cfg.link),\n    });\n\n    const $ = cheerio.load(response.data);\n    const list = $('article.details ul.list-unstyled li a')\n        .slice(0, 10)\n        .map((_, item) => {\n            item = $(item);\n            return {\n                title: item.find('div.title h3').text(),\n                link: item.attr('href'),\n                pubDate: get_date(item.find('time')),\n            };\n        })","sourceCodeStart":12,"sourceCodeEnd":48,"githubUrl":"https://github.com/DIYgod/RSSHub/blob/bed535e0879dc71c5aff6f1e7bd1ac21ede40115/lib/routes-deprecated/emi-nitta/home.js#L12-L48","documentation":"Thrown by the emi-nitta home route when ctx.params.type does not match a key in the route's config map (the `cfg` object that maps a type to a link). Only the configured types (news, live, etc. per the map) are valid.","triggerScenarios":"Request to /emi-nitta/:type with a type that is not one of the keys defined in the route's exported config object.","commonSituations":"Typo in the type segment; user guesses a type that was never configured; route's config map was edited and a previously-valid type removed.","solutions":["Use one of the types defined in the route's config map (check the route source for the keys).","Omit the segment if the route defines a sensible default (it does not here — supply a valid type).","If a legitimate type is missing, add it to the config map with its link."],"exampleFix":"// before\n/emi-nitta/foobar\n// after\n/emi-nitta/news","handlingStrategy":"type-guard","validationCode":"const cfg = CONFIG_MAP[ctx.params.type];\nif (!cfg) throw new Error('Bad type');","typeGuard":"const isValidType = (t: string): t is keyof typeof CONFIG_MAP =>\n  t in CONFIG_MAP;","tryCatchPattern":null,"preventionTips":["Derive the valid type list from the config map itself so docs cannot drift.","Reject unknown types at the route entry with a helpful message listing valid values."],"tags":["validation","routes","config"],"backgroundTag":null,"analyzedSha":"bed535e0879dc71c5aff6f1e7bd1ac21ede40115","analyzedAt":"2026-08-12T19:29:35.364Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}