{"record":{"id":"0bd53e912e06fd9f","repo":"jackwener/OpenCLI","slug":"fetch-error-0bd53e","errorCode":"FETCH_ERROR","errorMessage":"ctrip suggest fetch failed: ${err instanceof Error ? err.message : String(err)}","messagePattern":"ctrip suggest fetch failed: (.+?)","errorType":"error_code","errorClass":"CliError","httpStatus":null,"severity":"error","filePath":"clis/ctrip/utils.js","lineNumber":72,"sourceCode":"            body: JSON.stringify({\n                keyword: query,\n                searchType,\n                platform: 'online',\n                pageID: '102001',\n                head: {\n                    Locale: 'zh-CN',\n                    LocaleController: 'zh_cn',\n                    Currency: 'CNY',\n                    PageId: '102001',\n                    clientID: 'opencli-ctrip',\n                    group: 'ctrip',\n                    Frontend: { sessionID: 1, pvid: 1 },\n                    HotelExtension: { group: 'CTRIP', WebpSupport: false },\n                },\n            }),\n        });\n    } catch (err) {\n        throw new CliError(\n            'FETCH_ERROR',\n            `ctrip suggest fetch failed: ${err instanceof Error ? err.message : String(err)}`,\n            'Check your network connection and retry',\n        );\n    }\n    if (!response.ok) {\n        throw new CliError(\n            'FETCH_ERROR',\n            `ctrip suggest failed with status ${response.status}`,\n            'Retry the command or verify ctrip.com is reachable',\n        );\n    }\n    let payload;\n    try {\n        payload = await response.json();\n    } catch (err) {\n        throw new CliError(\n            'COMMAND_EXEC',","sourceCodeStart":54,"sourceCodeEnd":90,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/ctrip/utils.js#L54-L90","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\nconst rows = await fetchSuggest(keyword, 'D');\n// after\ntry {\n  const rows = await fetchSuggest(keyword, 'D');\n} catch (err) {\n  if (err.code === 'FETCH_ERROR') console.error('Network problem:', err.message);\n  throw err;\n}","handlingStrategy":"try-catch","validationCode":"if (typeof navigator !== 'undefined' && navigator.onLine === false) throw new Error('offline');","typeGuard":null,"tryCatchPattern":"try {\n  const rows = await fetchSuggest(keyword, 'D');\n} catch (err) {\n  if (err.code === 'FETCH_ERROR' && /fetch failed/i.test(err.message)) {\n    // network-level failure: prompt user to check connectivity/proxy\n  }\n  throw err;\n}","preventionTips":["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"],"tags":["network","fetch","cli"],"backgroundTag":"fetch-network-failure","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}