{"record":{"id":"8999f608c6908efa","repo":"DIYgod/RSSHub","slug":"unknown-bank-bank","errorCode":null,"errorMessage":"Unknown bank: ${bank}","messagePattern":"Unknown bank: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":503,"severity":"warning","filePath":"lib/routes/flyert/creditcard.ts","lineNumber":122,"sourceCode":"            bankname = '花旗银行';\n            break;\n        case 'shanghai':\n            bankname = '上海银行';\n            break;\n        case 'wuka':\n            bankname = '无卡支付';\n            break;\n        case '137':\n            bankname = '投资理财';\n            break;\n        case '145':\n            bankname = '网站权益汇';\n            break;\n        case 'intcreditcard':\n            bankname = '境外信用卡';\n            break;\n        default:\n            throw new Error(`Unknown bank: ${bank}`);\n    }\n\n    const response = await got.get(target, {\n        responseType: 'buffer',\n    });\n\n    const $ = load(gbk2utf8(response.data));\n\n    const list = $(\"[id*='normalthread']\").toArray();\n\n    const result = await util.ProcessFeed(list, cache);\n\n    return {\n        title: `飞客茶馆信用卡 - ${bankname}`,\n        link: 'https://www.flyert.com.cn/',\n        description: `飞客茶馆信用卡 - ${bankname}`,\n        item: result,\n    };","sourceCodeStart":104,"sourceCodeEnd":140,"githubUrl":"https://github.com/DIYgod/RSSHub/blob/bed535e0879dc71c5aff6f1e7bd1ac21ede40115/lib/routes/flyert/creditcard.ts#L104-L140","documentation":"Thrown by the Flyert credit card route's switch statement when the `bank` path parameter does not match any of the 18 known case values (creditcard, pufa, zhaoshang, zhongxin, jiaotong, zhonghang, gongshang, guangfa, nongye, jianshe, huifeng, mingsheng, xingye, huaqi, shanghai, wuka, 137, 145, intcreditcard). The error is a plain `Error` (not `InvalidParameterError`), which means it surfaces as a generic 500-level error rather than a 400-level parameter error. The switch also constructs the target URL `${host}/forum-${bank}-1.html` before the switch, so an invalid bank already produced a URL that would fail.","triggerScenarios":"A user passes a bank identifier not in the switch — e.g., `/flyert/creditcard/citic` (English name instead of pinyin), `/flyert/creditcard/ICBC`, or a typo like `/flyert/creditcard/zhongx`. The default case fires with the raw bank value.","commonSituations":"User guesses a bank name in English or abbreviated form instead of the expected pinyin slug. User uses uppercase instead of lowercase. The route documentation table is not consulted. A new bank section is added to the Flyert forum but not to this route.","solutions":["Use one of the documented bank identifiers: `creditcard`, `pufa`, `zhaoshang`, `zhongxin`, `jiaotong`, `zhonghang`, `gongshang`, `guangfa`, `nongye`, `jianshe`, `huifeng`, `mingsheng`, `xingye`, `huaqi`, `shanghai`, `wuka`, `137`, `145`, or `intcreditcard`.","Check the route description table in creditcard.ts for the complete mapping.","If the bank exists on flyert.com.cn but is not listed, request it be added or contribute a PR with a new case."],"exampleFix":"// before\ndefault:\n    throw new Error(`Unknown bank: ${bank}`);\n\n// after — use InvalidParameterError for proper 400-level response\ndefault:\n    throw new InvalidParameterError(`Unknown bank: ${bank}. Valid banks: creditcard, pufa, zhaoshang, zhongxin, jiaotong, zhonghang, gongshang, guangfa, nongye, jianshe, huifeng, mingsheng, xingye, huaqi, shanghai, wuka, 137, 145, intcreditcard`);","handlingStrategy":"validation","validationCode":"const VALID_BANKS = new Set([\n    'creditcard', 'pufa', 'zhaoshang', 'zhongxin', 'jiaotong', 'zhonghang',\n    'gongshang', 'guangfa', 'nongye', 'jianshe', 'huifeng', 'mingsheng',\n    'xingye', 'huaqi', 'shanghai', 'wuka', '137', '145', 'intcreditcard'\n]);\n\nfunction validateBank(bank: string | undefined): string {\n    if (!bank || !VALID_BANKS.has(bank)) {\n        throw new InvalidParameterError(`Unknown bank: ${bank}. Valid: ${[...VALID_BANKS].join(', ')}`);\n    }\n    return bank;\n}","typeGuard":"const BANK_IDS = ['creditcard','pufa','zhaoshang','zhongxin','jiaotong','zhonghang','gongshang','guangfa','nongye','jianshe','huifeng','mingsheng','xingye','huaqi','shanghai','wuka','137','145','intcreditcard'] as const;\ntype BankId = typeof BANK_IDS[number];\n\nfunction isBankId(value: string): value is BankId {\n    return (BANK_IDS as readonly string[]).includes(value);\n}","tryCatchPattern":null,"preventionTips":["Use only the documented bank identifiers from the route description table.","Replace the switch+throw with a Set-based validation + lookup map for cleaner code.","Use InvalidParameterError instead of plain Error for correct HTTP status (400 vs 500).","List all valid values in the error message so users can self-correct."],"tags":["parameter-validation","enum-check","error-class-mismatch","flyert"],"backgroundTag":null,"analyzedSha":"bed535e0879dc71c5aff6f1e7bd1ac21ede40115","analyzedAt":"2026-08-12T19:29:35.364Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}