jackwener/OpenCLI · info · EmptyResultError
coingecko exchanges
Error message
coingecko exchanges
What it means
This EmptyResultError is thrown when CoinGecko's /exchanges response parsed successfully but is not a non-empty array — i.e. the API returned `[]`, null, or an unexpected shape, meaning no exchange data exists for this request. It signals a legitimate empty/empty-ish result rather than a transport failure.
Source
Thrown at clis/coingecko/exchanges.js:61
}
if (resp.status === 429) {
throw new CommandExecutionError(
'coingecko returned HTTP 429 (rate limited)',
'Free tier allows ~30 calls/min. Wait and retry.',
);
}
if (!resp.ok) {
throw new CommandExecutionError(`coingecko exchanges returned HTTP ${resp.status}`);
}
let data;
try {
data = await resp.json();
}
catch (err) {
throw new CommandExecutionError(`coingecko exchanges returned malformed JSON: ${err?.message ?? err}`);
}
if (!Array.isArray(data) || !data.length) {
throw new EmptyResultError('coingecko exchanges', 'CoinGecko returned no exchange data.');
}
return data.map((ex, i) => ({
rank: (page - 1) * limit + i + 1,
id: String(ex.id ?? ''),
name: String(ex.name ?? ''),
trustScore: ex.trust_score != null ? Number(ex.trust_score) : null,
volume24hBtc: ex.trade_volume_24h_btc != null ? Number(ex.trade_volume_24h_btc) : null,
country: String(ex.country ?? ''),
yearEstablished: ex.year_established != null ? Number(ex.year_established) : null,
url: String(ex.url ?? ''),
}));
},
});
View on GitHub (pinned to 49907e53dc)
Solutions
- Stop paginating when this error occurs — you've passed the last page; use page 1..N where N is small (CoinGecko lists a few hundred exchanges).
- Increase per-page size (limit up to 250) to get everything in fewer pages, often a single page=1 call.
- Handle EmptyResultError in your wrapper as a normal end-of-data condition, not a failure.
- If the shape changed (API version change), check CoinGecko changelog and update the command.
Example fix
// before
for (let p = 1; ; p++) await exchanges.func({ page: p });
// after
for (let p = 1; p <= 10; p++) {
try { await exchanges.func({ page: p }); }
catch (e) { if (e.name === 'EmptyResultError') break; throw e; }
} Defensive patterns
Strategy: fallback
Try / catch
try {
const rows = await exchanges.func({ page });
} catch (e) {
if (e.name === 'EmptyResultError') return []; // normal end-of-pagination
throw e;
} Prevention
- Stop pagination on EmptyResultError instead of treating it as a crash.
- Fetch up to 250 per page; CoinGecko has only a few hundred exchanges, so page 1 often suffices.
- Track total pages from the first response instead of looping blindly.
- Expect [] when page exceeds result count — model it as end-of-data.
When it happens
Trigger: Requesting a page far beyond the last page of results (e.g. page=50 when only ~3 pages of exchanges exist), so CoinGecko returns an empty array; or the API changes its response shape from array to object/envelope.
Common situations: Pagination loops that don't stop when results run out, computing page numbers from stale total counts, or scripts assuming infinite pages.
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_DATA
- No trains found from ${fromStation.name} to ${toStation.name
- No Wayback snapshots for "${target}".
- No recruiter-side chat sessions were returned.
- Boss returned no messages for this chat.
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/d54ccb645c1a7fd1.
Report an issue: GitHub.