{"record":{"id":"f91c04214f632ae2","repo":"jackwener/OpenCLI","slug":"ctrip-search","errorCode":null,"errorMessage":"ctrip search","messagePattern":"ctrip search","errorType":"exception","errorClass":"EmptyResultError","httpStatus":null,"severity":"warning","filePath":"clis/ctrip/search.js","lineNumber":37,"sourceCode":"    columns: [\n        'rank', 'id', 'type', 'displayType', 'name', 'eName',\n        'cityId', 'cityName', 'provinceName', 'countryName',\n        'lat', 'lon', 'score', 'url',\n    ],\n    func: async (kwargs) => {\n        const query = String(kwargs.query || '').trim();\n        if (!query) {\n            throw new ArgumentError('Search keyword cannot be empty');\n        }\n        const limit = parseLimit(kwargs.limit);\n        const raw = await fetchSuggest(query, 'D');\n        const rows = raw\n            .filter((item) => !!item && typeof item === 'object')\n            .slice(0, limit)\n            .map(mapSuggestRow)\n            .filter((row) => row.name);\n        if (!rows.length) {\n            throw new EmptyResultError('ctrip search', 'Try a destination, scenic spot, or landmark keyword such as \"苏州\" or \"故宫\"');\n        }\n        return rows;\n    },\n});\n","sourceCodeStart":19,"sourceCodeEnd":42,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/ctrip/search.js#L19-L42","documentation":"An EmptyResultError thrown by `ctrip search` when Ctrip's suggest API returned data, but after filtering and mapping (mapSuggestRow), no row had a usable `name` — i.e. the search keyword matched nothing usable. The message suggests trying a destination, scenic spot, or landmark keyword such as 苏州 or 故宫.","triggerScenarios":"Calling `opencli ctrip search <keyword>` where fetchSuggest(query, 'D') returns rows that are all non-objects, filtered out, or map to rows without a name — e.g. misspelled place names, single Latin letters, brand names, or extremely obscure keywords Ctrip's destination suggest does not know.","commonSituations":"Typo'd or romanized keywords (\"sanya\" instead of 三亚); searching for hotels or restaurants rather than destinations; keywords in a language Ctrip suggest does not index; overly specific multi-word queries.","solutions":["Retry with a well-known Chinese destination keyword such as 苏州, 故宫, or 三亚","Use the destination's Chinese name rather than pinyin/English","Shorten the query to the city or landmark core (e.g. 马尔代夫 instead of 马尔代夫某岛)","Catch EmptyResultError and fall back to a broader keyword in your script"],"exampleFix":"// before\nconst rows = await runCli('ctrip', 'search', keyword); // throws when empty\n// after\nlet rows;\ntry {\n  rows = await runCli('ctrip', 'search', keyword);\n} catch (e) {\n  if (e.name === 'EmptyResultError') rows = await runCli('ctrip', 'search', fallbackKeyword);\n  else throw e;\n}","handlingStrategy":"fallback","validationCode":"const KNOWN = ['苏州','北京','三亚','故宫','马尔代夫'];\nif (!q || q.length < 2) console.warn('keyword may not match Ctrip suggest; consider a known destination');","typeGuard":null,"tryCatchPattern":"try {\n  const rows = await runCli('ctrip', 'search', keyword);\n} catch (e) {\n  if (e.name === 'EmptyResultError') {\n    const rows2 = await runCli('ctrip', 'search', broaderKeyword);\n  } else throw e;\n}","preventionTips":["Prefer Chinese destination/landmark keywords over pinyin or English","Shorten queries to the city or landmark core","Keep a curated fallback-keyword list for your use case","Treat EmptyResultError as data-absent, not a bug"],"tags":["empty-result","search","scraping","ctrip"],"backgroundTag":"empty-result-set","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}