DIYgod/RSSHub · error · Error
No such type
Error message
No such type
What it means
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.
Source
Thrown at lib/routes/whu/rsgis.ts:267
| 通知公告 | \`tzgg\` | 全部 | \`all\` |
| | | 学院通知 | \`xytz\` |
| | | 教学动态 | \`jxdt\` |
| | | 学术动态 | \`xsdt\` |
| | | 人才引进 | \`rcyj\` |`,
handler: async (ctx: Context) => {
const { type = 'index', sub = 'all' } = ctx.req.param();
let itemList: DataItem[];
switch (type) {
case 'index':
itemList = await handleIndex();
break;
case 'xyxw':
case 'kxyj':
case 'tzgg':
itemList = await handlePostList(type, sub);
break;
default:
throw new Error('No such type');
}
return {
title: `${categoryMap[type].name} - 武汉大学遥感信息工程学院`,
link: baseUrl,
description: `${categoryMap[type].name} - 武汉大学遥感信息工程学院`,
item: itemList,
};
},
};
View on GitHub (pinned to bed535e087)
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.
Example fix
// before /whu/rsgis/news // after /whu/rsgis/xyxw
Defensive patterns
Strategy: validation
Validate before calling
const VALID_TYPES = new Set(['index', 'xyxw', 'kxyj', 'tzgg']);
if (!VALID_TYPES.has(type)) {
throw new InvalidParameterError(`type must be one of ${[...VALID_TYPES].join(', ')} — got ${type}`);
} Type guard
function isRsgisType(v: string): v is 'index' | 'xyxw' | 'kxyj' | 'tzgg' {
return v === 'index' || v === 'xyxw' || v === 'kxyj' || v === 'tzgg';
} Try / catch
try {
// handler switch
} catch (e) {
if (e instanceof Error && e.message === 'No such type') {
return ctx.json({ error: 'Invalid type' }, 400);
}
throw e;
} Prevention
- 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.
When it happens
Trigger: Requesting /whu/rsgis/<bad> such as /whu/rsgis/news, /whu/rsgis/tzgg2, or a value that exists in another whu route but not here.
Common situations: Typo, guessing a type name, or mixing up whu sub-route namespaces.
Related errors
- Unknown type: ${type}
- Unknown type: ${type}
- Invalid type parameter
- No such sub type.
- Unknown product: ${product}
AI-assisted analysis of DIYgod/RSSHub@bed535e087 (2026-08-12).
Data as JSON: /api/errors/cccca3106abc0ef1.
Report an issue: GitHub.