jackwener/OpenCLI · error · CommandExecutionError
Failed to fetch quote for ${symbol}
Error message
Failed to fetch quote for ${symbol} What it means
Fallback CommandExecutionError in `clis/barchart/quote.js:114` when the quote fetch produced no data or returned an `error` field but that error string was empty/unavailable. It wraps the inner-script failure ('Could not fetch quote for ...') or the generic message so the CLI surfaces a consistent quote-fetch error.
Source
Thrown at clis/barchart/quote.js:114
percentChange: changePct,
open: openText,
highPrice: dayHigh ? dayHigh.textContent.trim() : null,
lowPrice: dayLow ? dayLow.textContent.trim() : null,
previousClose: fdata['Previous Close'] || null,
volume: fdata['Volume'] || null,
averageVolume: fdata['Average Volume'] || null,
marketCap: null,
peRatio: null,
earningsPerShare: null,
}
};
} catch(e) {
return { error: 'Could not fetch quote for ' + sym + ': ' + e.message };
}
})()
`);
if (!data || data.error)
throw new CommandExecutionError(data?.error || `Failed to fetch quote for ${symbol}`);
const r = data.row || {};
// API returns formatted strings like "+1.41" and "+0.56%"; use raw if available
const raw = r.raw || {};
return [{
symbol: r.symbol || symbol,
name: r.symbolName || r.name || symbol,
price: r.lastPrice ?? null,
change: r.priceChange ?? null,
changePct: r.percentChange ?? null,
open: r.openPrice ?? r.open ?? null,
high: r.highPrice ?? null,
low: r.lowPrice ?? null,
prevClose: r.previousPrice ?? r.previousClose ?? null,
volume: r.volume ?? null,
avgVolume: r.averageVolume ?? null,
marketCap: r.marketCap ?? null,
peRatio: r.peRatio ?? null,
eps: r.earningsPerShare ?? null,View on GitHub (pinned to 49907e53dc)
Solutions
- Read the underlying `error` message included in the thrown CommandExecutionError for the root cause.
- Check network reachability of barchart.com (proxy/VPN/DNS).
- Verify the symbol is valid and listed.
- Retry with backoff; Barchart may be rate-limiting or blocking the client.
Example fix
// before
throw new CommandExecutionError(data?.error || `Failed to fetch quote for ${symbol}`);
// after
const msg = data?.error || `Failed to fetch quote for ${symbol}`;
console.error(msg); // includes inner 'Could not fetch quote for X: <cause>'
throw new CommandExecutionError(msg); Defensive patterns
Strategy: try-catch
Validate before calling
function assertSymbol(s){ if (!/^[A-Z0-9.\-]{1,10}$/.test(s)) throw new Error(`invalid symbol: ${s}`); }
// also: const reachable = await fetch('https://barchart.com').then(r=>r.ok).catch(()=>false); Type guard
const isQuotePayload = (d) => !!d && typeof d === 'object' && !d.error && (typeof d.row === 'object' || 'symbol' in (d.row||{})); Try / catch
try {
const quote = await cli.run(['barchart','quote', symbol]);
} catch (e) {
if (e.message.startsWith('Failed to fetch quote')) {
console.error(e.message); // includes inner cause
// check connectivity, retry with backoff
}
} Prevention
- Read the inner cause embedded in the error message
- Check network/proxy reachability of barchart.com first
- Validate the symbol format before calling
- Retry with exponential backoff on transient failures
When it happens
Trigger: `barchart quote SYMBOL` where the in-page fetch throws (network error, timeout), Barchart blocks the request, or the script returns null/undefined data.
Common situations: Network outage or DNS failure to barchart.com, invalid/delisted symbol, rate limiting or bot detection serving an error page, expired session.
Understand the failure class
Background: 'Something went wrong' / 'Request failed (500)' / 'HTTP error! status: 404' — what failed HTTP requests actually mean and how to find the real cause — this error's family across 28 libraries.
Related errors
- Barchart greeks request failed: HTTP ${data.status}${data.st
- Barchart greeks request failed: ${data.message || 'unknown e
- 12306 queryByTrainNo returned HTTP ${resp.status}
- 12306 queryByTrainNo returned non-JSON body
- 12306 ${endpoint} returned non-JSON body
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/71af255f5b62aae3.
Report an issue: GitHub.