{"record":{"id":"ccc4edd93d78d5f9","repo":"DIYgod/RSSHub","slug":"unknown-type-type-ccc4ed","errorCode":null,"errorMessage":"Unknown type: ${type}","messagePattern":"Unknown type: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":503,"severity":"warning","filePath":"lib/routes/njnu/ceai/ceai.ts","lineNumber":47,"sourceCode":"\nasync function handler(ctx) {\n    const type = ctx.req.param('type');\n    let title, path;\n    switch (type) {\n        case 'xygg':\n            title = '学院公告';\n            path = '1651';\n            break;\n        case 'xyxw':\n            title = '学院新闻';\n            path = '1652';\n            break;\n        case 'xszx':\n            title = '学生资讯';\n            path = '1659';\n            break;\n        default:\n            throw new Error(`Unknown type: ${type}`);\n    }\n    const base = 'http://ceai.njnu.edu.cn/Item/List.asp?ID=' + path;\n\n    const response = await got(base);\n\n    const $ = load(response.data);\n\n    const list = $('span a').toArray();\n\n    const result = await util.ProcessFeed(list, cache);\n\n    return {\n        title: '南京师范大学计电人院 - ' + title,\n        link: 'http://ceai.njnu.edu.cn/',\n        description: '南京师范大学计电人院',\n        item: result,\n    };\n}","sourceCodeStart":29,"sourceCodeEnd":65,"githubUrl":"https://github.com/DIYgod/RSSHub/blob/bed535e0879dc71c5aff6f1e7bd1ac21ede40115/lib/routes/njnu/ceai/ceai.ts#L29-L65","documentation":"A plain Error thrown by the Nanjing Normal University (CEAI) route when the `type` path param does not match one of the switch cases (xygg / xyxw / xszx). It is a user-input validation guard, but uses a generic Error rather than InvalidParameterError, so it surfaces as a 500 rather than a 400.","triggerScenarios":"Calling /njnu/ceai/:type with a type outside {xygg, xyxw, xszx} — typos, unknown codes, or assumed category names. The switch has no graceful default.","commonSituations":"User mistypes the category code; user guesses a code; documentation drift between the route description and the switch cases.","solutions":["Use one of the documented type values: xygg (学院公告), xyxw (学院新闻), xszx (学生资讯).","Prefer throwing InvalidParameterError so RSSHub returns a 400 with a clear message instead of a 500.","If you maintain the route, consider a Map lookup with a single validation point like the njust routes."],"exampleFix":"// before\ndefault:\n    throw new Error(`Unknown type: ${type}`);\n\n// after\ndefault:\n    throw new InvalidParameterError(`Unknown type: ${type}. Valid: xygg, xyxw, xszx`);","handlingStrategy":"validation","validationCode":"const VALID = new Set(['xygg','xyxw','xszx']);\nfunction buildCeaiUrl(type) {\n  if (!VALID.has(type)) throw new Error(`Unknown type '${type}'. Valid: ${[...VALID].join(', ')}`);\n  return 'http://ceai.njnu.edu.cn/Item/List.asp?ID=' + MAP[type];\n}","typeGuard":"const isCeaiType = (t: string): t is 'xygg'|'xyxw'|'xszx' => VALID.has(t);","tryCatchPattern":null,"preventionTips":["Validate the type client-side before hitting the route.","Use InvalidParameterError so the response is a 400, not a 500.","Document the valid codes alongside the URL in client tooling."],"tags":["validation","route-parameter","user-input","njnu"],"backgroundTag":null,"analyzedSha":"bed535e0879dc71c5aff6f1e7bd1ac21ede40115","analyzedAt":"2026-08-12T19:29:35.364Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}