DIYgod/RSSHub · error · Error

Error fetching announcements: ${error}

Error message

Error fetching announcements: ${error}

What it means

Catch-all wrapping the entire /xbmu/announcement handler; identical pattern to the academic route. Any exception during list/detail fetch or parse is re-thrown with an 'Error fetching announcements:' prefix and { cause: error }.

Source

Thrown at lib/routes/xbmu/announcement.ts:73

                            description: content,
                            category: ['university'],
                            guid: item.link,
                            id: item.link,
                            image: 'http://210.26.0.114:9090/mdxg/img/weex/default_img.jpg',
                            content,
                            updated: item.date,
                            language: 'zh-CN',
                        };
                    })
                )
            )) as DataItem[],
            allowEmpty: true,
            language: 'zh-CN',
            feedLink: 'https://rsshub.app/xbmu/announcement',
            id: 'https://rsshub.app/xbmu/announcement',
        };
    } catch (error) {
        throw new Error(`Error fetching announcements: ${error}`, { cause: error });
    }
};

export const route: Route = {
    path: '/announcement',
    name: '通知公告',
    maintainers: ['PrinOrange'],
    handler,
    categories: ['university'],
    features: {
        requireConfig: false,
        requirePuppeteer: false,
        antiCrawler: false,
        supportBT: false,
        supportPodcast: false,
        supportScihub: false,
    },
    example: '/xbmu/announcement',

View on GitHub (pinned to bed535e087)

Solutions

  1. Read error.cause to find the underlying HTTP/parse error.
  2. Confirm https://www.xbmu.edu.cn/xwzx/tzgg.htm is reachable and returns the expected HTML.
  3. If selectors drifted, update announcement.ts:17 and report upstream.
Defensive patterns

Strategy: try-catch

Validate before calling

try {
    const r = await got.head('https://www.xbmu.edu.cn/xwzx/tzgg.htm', { timeout: 5000 });
    if (r.statusCode >= 400) throw new Error(`xbmu returned ${r.statusCode}`);
} catch {
    throw new Error('xbmu announcement source unreachable');
}

Type guard

function isXbmuAnnouncementError(e: unknown): boolean {
    return e instanceof Error && /Error fetching announcements/i.test(e.message);
}

Try / catch

try {
    return await xbmuAnnouncementHandler();
} catch (e) {
    const root = isXbmuAnnouncementError(e) ? (e.cause ?? e) : e;
    if (root instanceof Error && /ENOTFOUND|ETIMEDOUT/i.test(root.message)) {
        await scheduleRetry();
    }
    throw e;
}

Prevention

When it happens

Trigger: got(BASE_URL) (tzgg.htm) or got(item.link) fails, or load()/cheerio throws on bad HTML, caught at announcement.ts:72-74.

Common situations: Announcement page (tzgg.htm) unreachable, returning a redirect/error page, or markup changed so ITEM_SELECTOR matches nothing (which itself does not throw but indicates staleness).

Related errors


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