DIYgod/RSSHub · error · Error
response.statusMessage
Error message
response.statusMessage
What it means
Thrown by the Taiyuan Human Resources bureau route when the upstream HTTP response from `rsj.taiyuan.gov.cn` has a non-200 status. The handler throws `response.statusMessage` as a plain `Error`. Like the zzb route, `statusMessage` may be empty for some status codes, yielding an unhelpful error.
Source
Thrown at lib/routes/gov/taiyuan/rsj.ts:48
handler,
url: 'rsj.taiyuan.gov.cn/*',
description: `| 工作动态 | 太原新闻 | 通知公告 | 县区动态 | 国内动态 | 图片新闻 |
| -------- | -------- | -------- | -------- | -------- | -------- |
| gzdt | tyxw | gggs | xqdt | gndt | tpxw |`,
};
async function handler(ctx) {
const categoryID = ctx.req.param('caty');
const page = ctx.req.param('page') ?? '1';
const pageParam = Number.parseInt(page) > 1 ? `_${page}` : '';
const pagePath = `/zfxxgk/${categoryID}/index${pageParam}.shtml`;
const currentURL = new URL(pagePath, rootURL);
const response = await got(currentURL.href);
if (response.statusCode !== 200) {
throw new Error(response.statusMessage);
}
const $ = load(response.data, { decodeEntities: false } as CheerioOptions);
const title = $('.tit').find('a:eq(2)').text();
const list = $('.RightSide_con ul li')
.toArray()
.map((item) => {
const link = $(item).find('a');
const date = $(item).find('span.fr');
return {
title: link.attr('title')!,
link: link.attr('href'),
pubDate: timezone(parseDate(date.text(), 'YYYY-MM-DD'), 8),
};
});
return {
title: '太原市人力资源和社会保障局 - ' + title,View on GitHub (pinned to bed535e087)
Solutions
- Verify `http://rsj.taiyuan.gov.cn/zfxxgk/<caty>/index.shtml` loads in a browser.
- Use one of the documented categories: `gzdt`, `tyxw`, `gggs`, `xqdt`, `gndt`, `tpxw`.
- Retry later if the upstream is temporarily unavailable.
- Maintainer fix: include the URL and status code in the thrown error for diagnostics.
Example fix
// before
if (response.statusCode !== 200) {
throw new Error(response.statusMessage);
}
// after
if (response.statusCode !== 200) {
throw new Error(`rsj.taiyuan.gov.cn returned ${response.statusCode} for ${currentURL.href}`);
} Defensive patterns
Strategy: try-catch
Validate before calling
const VALID_CATEGORIES = ['gzdt', 'tyxw', 'gggs', 'xqdt', 'gndt', 'tpxw'] as const;
function isValidCategory(caty: string): boolean {
return (VALID_CATEGORIES as readonly string[]).includes(caty);
}
// Validate before the HTTP request to avoid confusing upstream errors. Type guard
function isValidRsjCategory(caty: string): caty is typeof VALID_CATEGORIES[number] {
return (VALID_CATEGORIES as readonly string[]).includes(caty);
} Try / catch
try {
const response = await got(currentURL.href);
if (response.statusCode !== 200) {
throw new Error(`rsj.taiyuan.gov.cn returned ${response.statusCode} for ${currentURL.href}`);
}
} catch (err) {
throw new Error(`Failed to fetch from rsj.taiyuan.gov.cn: ${err instanceof Error ? err.message : String(err)}`);
} Prevention
- Pre-validate the category slug against the known set before making the HTTP request.
- Include the URL and status code in thrown errors.
- Cache successful responses to reduce upstream load.
When it happens
Trigger: The upstream site returns non-200 for the constructed URL `/zfxxgk/<caty>/index[_page].shtml`. The `caty` parameter is free-form and the page number is unbounded.
Common situations: Wrong category slug that does not correspond to a real directory, requesting a page beyond available pages, upstream maintenance, or the site blocking the RSSHub user-agent.
Related errors
- response.statusMessage
- response.statusMessage
- 中国政府网搜索接口请求失败,错误代码:${response?.resultCode?.code ?? '未知'}
- Unable to access the Locals server function (${response.stat
- Twitter API error: ${response.status}
AI-assisted analysis of DIYgod/RSSHub@bed535e087 (2026-08-12).
Data as JSON: /api/errors/2fee53a20be1b6bf.
Report an issue: GitHub.