DIYgod/RSSHub · error · Error

response.statusMessage

Error message

response.statusMessage

What it means

Thrown by the Shenzhen Organization Department (zzb) route when the upstream HTTP response from `www.zzb.sz.gov.cn` has a status code other than 200. The handler re-throws `response.statusMessage` directly as a plain `Error`. The `statusMessage` property on Node HTTP responses can be undefined or an empty string for certain status codes (e.g. some proxies and CDNs omit it), producing an error with no useful text.

Source

Thrown at lib/routes/gov/shenzhen/zzb/index.ts:47

    maintainers: ['zlasd'],
    handler,
    url: 'zzb.sz.gov.cn/*',
    description: `| 通知公告 | 任前公示 | 政策法规 | 工作动态 | 部门预算决算公开 | 业务表格下载 |
| :------: | :------: | :------: | :------: | :--------------: | :----------: |
|   tzgg   |   rqgs   |   zcfg   |   gzdt   |       xcbd       |     bgxz     |`,
};

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 = `/${categoryID}/index${pageParam}.html`;

    const currentURL = new URL(pagePath, rootURL); // do not use deprecated 'url.resolve'
    const response = await got({ method: 'get', url: currentURL });
    if (response.statusCode !== 200) {
        throw new Error(response.statusMessage);
    }

    const $ = load(response.data);
    const title = $('#Title').text().trim();
    const list = $('#List tbody tr td table tbody tr td[width="96%"]')
        .toArray()
        .map((item) => {
            const tag = $(item).find('font a');
            const tag2 = $(item).find('font[size="2px"]');
            return {
                title: tag.text(),
                link: tag.attr('href'),
                pubDate: timezone(parseDate(tag2.text().trim(), 'YYYY/MM/DD'), 0),
            };
        });

    return {
        title: '深圳组工在线 - ' + title,

View on GitHub (pinned to bed535e087)

Solutions

  1. Open `http://www.zzb.sz.gov.cn/<caty>/index.html` in a browser to verify the page exists and the site is up.
  2. Ensure the page number is within range (start with page 1 or omit it).
  3. Retry later if the upstream is in maintenance.
  4. As a maintainer fix: replace `throw new Error(response.statusMessage)` with a descriptive message including the URL and status code, and fall back to a generic string when `statusMessage` is empty.

Example fix

// before
if (response.statusCode !== 200) {
    throw new Error(response.statusMessage);
}

// after
if (response.statusCode !== 200) {
    throw new Error(`Upstream zzb.sz.gov.cn returned ${response.statusCode} ${response.statusMessage || ''} for ${currentURL.href}`.trim());
}
Defensive patterns

Strategy: try-catch

Try / catch

let response;
try {
    response = await got({ method: 'get', url: currentURL });
} catch (err) {
    throw new Error(`Failed to reach zzb.sz.gov.cn: ${err instanceof Error ? err.message : String(err)}`);
}
if (response.statusCode !== 200) {
    throw new Error(`zzb.sz.gov.cn returned HTTP ${response.statusCode} for ${currentURL.href}`);
}

Prevention

When it happens

Trigger: The upstream government site returns 404 (bad category/page path), 500/502/503 (server error or maintenance), or the constructed URL `/[caty]/index[_page].html` does not resolve. The page parameter is user-supplied and unbounded.

Common situations: Upstream site maintenance windows, requesting a page number beyond the available pages (e.g. `/gov/shenzhen/zzb/tzgg/999`), DNS/network issues, or anti-crawler blocks returning non-200 status codes.

Related errors


AI-assisted analysis of DIYgod/RSSHub@bed535e087 (2026-08-12). Data as JSON: /api/errors/56643204344c9a63. Report an issue: GitHub.