jackwener/OpenCLI · error · CliError
FETCH_ERROR
FETCH_ERROR
Error message
ctrip suggest fetch failed: ${err instanceof Error ? err.message : String(err)} What it means
fetchSuggest wraps any failure of the fetch() call to Ctrip's hotel/destination suggest endpoint (m.ctrip.com/restapi/soa2/21881/json/gaHotelSearchEngine) in a CliError with code FETCH_ERROR. The original error message (network failure, DNS failure, TLS error, abort) is embedded in the message. It exists so callers get a consistent typed error instead of a raw fetch exception.
Source
Thrown at clis/ctrip/utils.js:72
body: JSON.stringify({
keyword: query,
searchType,
platform: 'online',
pageID: '102001',
head: {
Locale: 'zh-CN',
LocaleController: 'zh_cn',
Currency: 'CNY',
PageId: '102001',
clientID: 'opencli-ctrip',
group: 'ctrip',
Frontend: { sessionID: 1, pvid: 1 },
HotelExtension: { group: 'CTRIP', WebpSupport: false },
},
}),
});
} catch (err) {
throw new CliError(
'FETCH_ERROR',
`ctrip suggest fetch failed: ${err instanceof Error ? err.message : String(err)}`,
'Check your network connection and retry',
);
}
if (!response.ok) {
throw new CliError(
'FETCH_ERROR',
`ctrip suggest failed with status ${response.status}`,
'Retry the command or verify ctrip.com is reachable',
);
}
let payload;
try {
payload = await response.json();
} catch (err) {
throw new CliError(
'COMMAND_EXEC',View on GitHub (pinned to 49907e53dc)
Solutions
- Check network connectivity (can you curl https://m.ctrip.com?)
- Configure HTTPS_PROXY/HTTP_PROXY env vars if behind a proxy
- Retry the command; the failure may be transient
- Verify m.ctrip.com is not blocked by firewall/VPN policy
Example fix
// before
const rows = await fetchSuggest(keyword, 'D');
// after
try {
const rows = await fetchSuggest(keyword, 'D');
} catch (err) {
if (err.code === 'FETCH_ERROR') console.error('Network problem:', err.message);
throw err;
} Defensive patterns
Strategy: try-catch
Validate before calling
if (typeof navigator !== 'undefined' && navigator.onLine === false) throw new Error('offline'); Try / catch
try {
const rows = await fetchSuggest(keyword, 'D');
} catch (err) {
if (err.code === 'FETCH_ERROR' && /fetch failed/i.test(err.message)) {
// network-level failure: prompt user to check connectivity/proxy
}
throw err;
} Prevention
- Check connectivity before invoking network CLI commands
- Configure proxy env vars in restricted networks
- Add retry with backoff around suggest calls
- Keep a fallback data source for critical workflows
When it happens
Trigger: Calling fetchSuggest(query, searchType) when the POST to the Ctrip endpoint throws: no network connection, DNS resolution failure for m.ctrip.com, TLS/proxy errors, request blocked by firewall, or fetch aborted.
Common situations: Developer runs the CLI offline or behind a corporate proxy that blocks m.ctrip.com; DNS misconfiguration; VPN required to reach Chinese sites from abroad; endpoint temporarily unreachable.
Related errors
- archive search request failed: ${error?.message || error}
- coingecko trending request failed: ${error?.message || error
- hf paper request failed: ${err?.message ?? err}
- hf spaces request failed: ${err?.message ?? err}
- mdn search request failed: ${err?.message ?? err}
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/0bd53e912e06fd9f.
Report an issue: GitHub.