{"record":{"id":"1a3a2bfda893bb23","repo":"jackwener/OpenCLI","slug":"sinafinance-rolling-news","errorCode":null,"errorMessage":"sinafinance rolling-news","messagePattern":"sinafinance rolling-news","errorType":"exception","errorClass":"EmptyResultError","httpStatus":null,"severity":"info","filePath":"clis/sinafinance/rolling-news.js","lineNumber":35,"sourceCode":"function formatRollTimestamp(value) {\n    const seconds = Number(value);\n    if (!Number.isFinite(seconds) || seconds <= 0)\n        return '';\n    // Sina's roll page presents finance news in China Standard Time.\n    const date = new Date(seconds * 1000 + 8 * 60 * 60 * 1000);\n    return `${pad2(date.getUTCMonth() + 1)}-${pad2(date.getUTCDate())} ${pad2(date.getUTCHours())}:${pad2(date.getUTCMinutes())}`;\n}\n\nfunction normalizeRollRows(payload) {\n    if (payload?.result?.status?.code !== 0) {\n        throw new CommandExecutionError(`Sina Finance rolling news API failed: ${payload?.result?.status?.msg || 'unknown status'}`);\n    }\n    const items = payload?.result?.data;\n    if (!Array.isArray(items)) {\n        throw new CommandExecutionError('Sina Finance rolling news API returned malformed data');\n    }\n    if (items.length === 0) {\n        throw new EmptyResultError('sinafinance rolling-news');\n    }\n    return items.map((item, index) => {\n        const title = typeof item?.title === 'string' ? item.title.trim() : '';\n        const url = typeof item?.url === 'string' ? item.url.trim() : '';\n        const date = formatRollTimestamp(item?.ctime);\n        if (!title || !url || !date) {\n            throw new CommandExecutionError(`Sina Finance rolling news API returned malformed row ${index + 1}`);\n        }\n        return {\n            column: '财经',\n            title,\n            date,\n            url,\n        };\n    });\n}\n\ncli({","sourceCodeStart":17,"sourceCodeEnd":53,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/sinafinance/rolling-news.js#L17-L53","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  const rows = await cli.rollingNews();\n} catch (err) {\n  if (err instanceof EmptyResultError || /rolling-news/.test(err.message)) {\n    return []; // expected empty state, not a failure\n  }\n  throw err;\n}","preventionTips":["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"],"tags":["empty-result","no-data"],"backgroundTag":"empty-result-set","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}