{"record":{"id":"d3d0a4b9bc362257","repo":"jackwener/OpenCLI","slug":"ctrip-hotel-suggest","errorCode":null,"errorMessage":"ctrip hotel-suggest","messagePattern":"ctrip hotel-suggest","errorType":"exception","errorClass":"EmptyResultError","httpStatus":null,"severity":"info","filePath":"clis/ctrip/hotel-suggest.js","lineNumber":41,"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, 'H');\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 hotel-suggest', 'Try a city, business area, or hotel keyword such as \"陆家嘴\" or \"汉庭酒店\"');\n        }\n        return rows;\n    },\n});\n","sourceCodeStart":23,"sourceCodeEnd":46,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/ctrip/hotel-suggest.js#L23-L46","documentation":"EmptyResultError thrown when the Ctrip suggest endpoint returned data but, after filtering non-objects and rows without a name, no usable suggestions remain. The library treats an empty suggestion set as a user-facing condition worth its own error type rather than returning []. The message suggests alternative keywords.","triggerScenarios":"fetchSuggest returns entries that are all null/non-objects or lack a name field, or the endpoint returns an empty array for a query with no matches (misspelled keyword, very obscure location).","commonSituations":"Searching gibberish or over-specific keywords; Ctrip returning region-gated empty results; API shape change removing the name field from suggest items; slicing with limit 0 via a bad --limit argument.","solutions":["Retry with a broader or correctly spelled keyword (e.g. a city or hotel brand)","Check the --limit value is > 0","Inspect fetchSuggest output and update mapSuggestRow if the name field moved","Try a Chinese-language keyword if searching the international site"],"exampleFix":"// before\nawait ctrip.hotelSuggest({ query: 'xqzzy', limit: 0 });\n// after\nawait ctrip.hotelSuggest({ query: '陆家嘴', limit: 10 });","handlingStrategy":"fallback","validationCode":"if (!query || !query.trim()) throw new Error('query required');\nconst limit = Number(kwargs.limit ?? 10);\nif (!Number.isInteger(limit) || limit <= 0) throw new Error('limit must be a positive integer');","typeGuard":"const isNamedSuggestion = (item) => !!item && typeof item === 'object' && typeof item.name === 'string' && item.name.length > 0;","tryCatchPattern":"try {\n  return await ctrip.hotelSuggest({ query });\n} catch (e) {\n  if (e instanceof EmptyResultError) {\n    return []; // or retry with a broadened keyword\n  }\n  throw e;\n}","preventionTips":["Prefer well-known city/area/brand keywords","Retry with progressively broader queries","Ensure limit > 0","Handle EmptyResultError as a normal UX branch, not a crash"],"tags":["empty-result","search","ctrip"],"backgroundTag":"empty-result-set","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}