{"record":{"id":"ba991bb1629f8fd8","repo":"DIYgod/RSSHub","slug":"unknown-type-type-ba991b","errorCode":null,"errorMessage":"Unknown type: ${type}","messagePattern":"Unknown type: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":503,"severity":"warning","filePath":"lib/routes/njnu/jwc/jwc.ts","lineNumber":47,"sourceCode":"\nasync function handler(ctx) {\n    const type = ctx.req.param('type');\n    let title, path;\n    switch (type) {\n        case 'jstz':\n            title = '教师通知';\n            path = 'jstz.htm';\n            break;\n        case 'xwdt':\n            title = '新闻动态';\n            path = 'xwdt.htm';\n            break;\n        case 'xstz':\n            title = '学生通知';\n            path = 'xstz.htm';\n            break;\n        default:\n            throw new Error(`Unknown type: ${type}`);\n    }\n    const base = 'http://jwc.njnu.edu.cn/index/' + path;\n\n    const response = await got(base);\n\n    const $ = load(response.data);\n\n    const list = $('.list_txt a').toArray();\n\n    const result = await ProcessFeed(list, cache);\n\n    return {\n        title: '南京师范大学教务处 - ' + title,\n        link: 'http://jwc.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/jwc/jwc.ts#L29-L65","documentation":"Same switch-default guard as 410, in the NJNU JWC (教务处) route. Type must be one of jstz / xwdt / xstz; anything else throws a generic Error 'Unknown type'. Returns a 500 to the client.","triggerScenarios":"Calling /njnu/jwc/:type with a value not in {jstz, xwdt, xstz} — typo, unknown code, or a category that does not exist for this sub-site.","commonSituations":"Mistyped category code; assumed codes copied from a different NJNU sub-site that uses different keys.","solutions":["Use one of jstz (教师通知), xwdt (新闻动态), xstz (学生通知).","If maintaining the route, switch to InvalidParameterError for a correct 400 response.","Align the type codes across all njnu/* routes to reduce user confusion."],"exampleFix":"// before\ndefault:\n    throw new Error(`Unknown type: ${type}`);\n\n// after\ndefault:\n    throw new InvalidParameterError(`Unknown type: ${type}. Valid: jstz, xwdt, xstz`);","handlingStrategy":"validation","validationCode":"const VALID = new Set(['jstz','xwdt','xstz']);\nfunction buildJwcUrl(type) {\n  if (!VALID.has(type)) throw new Error(`Unknown type '${type}'. Valid: ${[...VALID].join(', ')}`);\n  return 'http://jwc.njnu.edu.cn/index/' + MAP[type];\n}","typeGuard":"const isJwcType = (t: string): t is 'jstz'|'xwdt'|'xstz' => VALID.has(t);","tryCatchPattern":null,"preventionTips":["Validate type before requesting.","Prefer InvalidParameterError for a correct 400 status.","Keep type codes consistent across all njnu/* routes where possible."],"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"}