DIYgod/RSSHub · warning · Error
Unknown type: ${type}
Error message
Unknown type: ${type} What it means
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.
Source
Thrown at lib/routes/njnu/jwc/jwc.ts:47
async function handler(ctx) {
const type = ctx.req.param('type');
let title, path;
switch (type) {
case 'jstz':
title = '教师通知';
path = 'jstz.htm';
break;
case 'xwdt':
title = '新闻动态';
path = 'xwdt.htm';
break;
case 'xstz':
title = '学生通知';
path = 'xstz.htm';
break;
default:
throw new Error(`Unknown type: ${type}`);
}
const base = 'http://jwc.njnu.edu.cn/index/' + path;
const response = await got(base);
const $ = load(response.data);
const list = $('.list_txt a').toArray();
const result = await ProcessFeed(list, cache);
return {
title: '南京师范大学教务处 - ' + title,
link: 'http://jwc.njnu.edu.cn/',
description: '南京师范大学教务处',
item: result,
};
}View on GitHub (pinned to bed535e087)
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.
Example fix
// before
default:
throw new Error(`Unknown type: ${type}`);
// after
default:
throw new InvalidParameterError(`Unknown type: ${type}. Valid: jstz, xwdt, xstz`); Defensive patterns
Strategy: validation
Validate before calling
const VALID = new Set(['jstz','xwdt','xstz']);
function buildJwcUrl(type) {
if (!VALID.has(type)) throw new Error(`Unknown type '${type}'. Valid: ${[...VALID].join(', ')}`);
return 'http://jwc.njnu.edu.cn/index/' + MAP[type];
} Type guard
const isJwcType = (t: string): t is 'jstz'|'xwdt'|'xstz' => VALID.has(t);
Prevention
- Validate type before requesting.
- Prefer InvalidParameterError for a correct 400 status.
- Keep type codes consistent across all njnu/* routes where possible.
When it happens
Trigger: 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.
Common situations: Mistyped category code; assumed codes copied from a different NJNU sub-site that uses different keys.
Related errors
- Unknown type: ${type}
- Invalid type parameter
- Invalid type parameter
- Invalid category: ${category}
- Unsupported region code: ${region}
AI-assisted analysis of DIYgod/RSSHub@bed535e087 (2026-08-12).
Data as JSON: /api/errors/ba991bb1629f8fd8.
Report an issue: GitHub.