{"record":{"id":"cccca3106abc0ef1","repo":"DIYgod/RSSHub","slug":"no-such-type","errorCode":null,"errorMessage":"No such type","messagePattern":"No such type","errorType":"validation","errorClass":"Error","httpStatus":503,"severity":"error","filePath":"lib/routes/whu/rsgis.ts","lineNumber":267,"sourceCode":"| 通知公告 | \\`tzgg\\`    |   全部   | \\`all\\`    |\n|          |           | 学院通知 | \\`xytz\\`   |\n|          |           | 教学动态 | \\`jxdt\\`   |\n|          |           | 学术动态 | \\`xsdt\\`   |\n|          |           | 人才引进 | \\`rcyj\\`   |`,\n    handler: async (ctx: Context) => {\n        const { type = 'index', sub = 'all' } = ctx.req.param();\n        let itemList: DataItem[];\n        switch (type) {\n            case 'index':\n                itemList = await handleIndex();\n                break;\n            case 'xyxw':\n            case 'kxyj':\n            case 'tzgg':\n                itemList = await handlePostList(type, sub);\n                break;\n            default:\n                throw new Error('No such type');\n        }\n\n        return {\n            title: `${categoryMap[type].name} - 武汉大学遥感信息工程学院`,\n            link: baseUrl,\n            description: `${categoryMap[type].name} - 武汉大学遥感信息工程学院`,\n            item: itemList,\n        };\n    },\n};\n","sourceCodeStart":249,"sourceCodeEnd":278,"githubUrl":"https://github.com/DIYgod/RSSHub/blob/bed535e0879dc71c5aff6f1e7bd1ac21ede40115/lib/routes/whu/rsgis.ts#L249-L278","documentation":"The route /whu/rsgis/:type/:sub? only accepts type in {index, xyxw, kxyj, tzgg}. Any other type value hits the switch default before any data is fetched.","triggerScenarios":"Requesting /whu/rsgis/<bad> such as /whu/rsgis/news, /whu/rsgis/tzgg2, or a value that exists in another whu route but not here.","commonSituations":"Typo, guessing a type name, or mixing up whu sub-route namespaces.","solutions":["Use one of: index, xyxw, kxyj, tzgg (see route description).","For the landing feed use /whu/rsgis/index.","Confirm you are on the right whu route — cs uses integers, rsgis uses string keys."],"exampleFix":"// before\n/whu/rsgis/news\n// after\n/whu/rsgis/xyxw","handlingStrategy":"validation","validationCode":"const VALID_TYPES = new Set(['index', 'xyxw', 'kxyj', 'tzgg']);\nif (!VALID_TYPES.has(type)) {\n    throw new InvalidParameterError(`type must be one of ${[...VALID_TYPES].join(', ')} — got ${type}`);\n}","typeGuard":"function isRsgisType(v: string): v is 'index' | 'xyxw' | 'kxyj' | 'tzgg' {\n    return v === 'index' || v === 'xyxw' || v === 'kxyj' || v === 'tzgg';\n}","tryCatchPattern":"try {\n    // handler switch\n} catch (e) {\n    if (e instanceof Error && e.message === 'No such type') {\n        return ctx.json({ error: 'Invalid type' }, 400);\n    }\n    throw e;\n}","preventionTips":["Use a literal-union type for type so the compiler enforces the switch exhaustiveness.","Return InvalidParameterError for unknown types so RSSHub returns 4xx.","Keep the route description table and the switch cases in lockstep."],"tags":["whu","route-parameter","validation","switch-default"],"backgroundTag":null,"analyzedSha":"bed535e0879dc71c5aff6f1e7bd1ac21ede40115","analyzedAt":"2026-08-12T19:29:35.364Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}