jackwener/OpenCLI · info · EmptyResultError
sinafinance rolling-news
Error message
sinafinance rolling-news
What it means
EmptyResultError('sinafinance rolling-news') thrown when the rolling news API succeeds (status 0, data is an array) but contains zero items. This is a typed empty-result signal so callers can distinguish 'no news right now' from failures.
Source
Thrown at clis/sinafinance/rolling-news.js:35
function formatRollTimestamp(value) {
const seconds = Number(value);
if (!Number.isFinite(seconds) || seconds <= 0)
return '';
// Sina's roll page presents finance news in China Standard Time.
const date = new Date(seconds * 1000 + 8 * 60 * 60 * 1000);
return `${pad2(date.getUTCMonth() + 1)}-${pad2(date.getUTCDate())} ${pad2(date.getUTCHours())}:${pad2(date.getUTCMinutes())}`;
}
function normalizeRollRows(payload) {
if (payload?.result?.status?.code !== 0) {
throw new CommandExecutionError(`Sina Finance rolling news API failed: ${payload?.result?.status?.msg || 'unknown status'}`);
}
const items = payload?.result?.data;
if (!Array.isArray(items)) {
throw new CommandExecutionError('Sina Finance rolling news API returned malformed data');
}
if (items.length === 0) {
throw new EmptyResultError('sinafinance rolling-news');
}
return items.map((item, index) => {
const title = typeof item?.title === 'string' ? item.title.trim() : '';
const url = typeof item?.url === 'string' ? item.url.trim() : '';
const date = formatRollTimestamp(item?.ctime);
if (!title || !url || !date) {
throw new CommandExecutionError(`Sina Finance rolling news API returned malformed row ${index + 1}`);
}
return {
column: '财经',
title,
date,
url,
};
});
}
cli({View on GitHub (pinned to 49907e53dc)
Solutions
- Remove or widen page/time parameters to request the default window
- Retry later — the feed may simply have no items yet
- Treat as an expected empty state in automation rather than an error
- Fall back to the regular news command for broader coverage
Defensive patterns
Strategy: fallback
Try / catch
try {
const rows = await cli.rollingNews();
} catch (err) {
if (err instanceof EmptyResultError || /rolling-news/.test(err.message)) {
return []; // expected empty state, not a failure
}
throw err;
} Prevention
- Don't page past available results
- Treat EmptyResultError as a normal empty state in schedulers
- Fall back to the broader news command when rolling news is empty
- Avoid querying overly narrow time windows
When it happens
Trigger: Fetching rolling news when Sina's feed has no entries for the requested time window/page — e.g. requesting page N beyond available results, or an extremely narrow time range with no published items.
Common situations: Paging past the end of available rolling news; querying during a quiet period (overnight/holiday) with filters that exclude everything; automated jobs polling a specific window that has no items.
Understand the failure class
Background: EmptyResultError / "no results found": when an API or scraper succeeds but returns zero rows — this error's family across 9 libraries.
Related errors
- No trains found from ${fromStation.name} to ${toStation.name
- NO_DATA
- No Wayback snapshots for "${target}".
- Chess.com has no game archives for ${username}
- Chess.com has games archives for ${username} but no games in
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/1a3a2bfda893bb23.
Report an issue: GitHub.