{"record":{"id":"ebce61402937d29e","repo":"DIYgod/RSSHub","slug":"error-ebce61","errorCode":null,"errorMessage":"未知的金属类型","messagePattern":"未知的金属类型","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"lib/routes/ccmn/price-adjustment.tsx","lineNumber":91,"sourceCode":"    pb: 'pb.ccmn.cn',\n    ni: 'ni.ccmn.cn',\n};\n\nconst READABLE_CATEGORIES = {\n    copper: '铜',\n    alu: '铝',\n    zn: '锌',\n    sn: '锡',\n    pb: '铅',\n    ni: '镍',\n};\n\nasync function handler(ctx) {\n    const category = ctx.req.param('category');\n\n    const subdomain = SUB_DOMAIN_MAP[category];\n    if (!subdomain) {\n        throw new Error('未知的金属类型');\n    }\n\n    const url = `https://${subdomain}`;\n\n    const response = await got({\n        method: 'get',\n        url,\n    });\n\n    const $ = load(response.data);\n\n    const items = $('.content1-text-div')\n        .toArray()\n        .map((item) => {\n            const $item = $(item);\n            const dataId = $item.attr('data-id');\n\n            const $top = $item.find('.top');","sourceCodeStart":73,"sourceCodeEnd":109,"githubUrl":"https://github.com/DIYgod/RSSHub/blob/bed535e0879dc71c5aff6f1e7bd1ac21ede40115/lib/routes/ccmn/price-adjustment.tsx#L73-L109","documentation":"The 长江有色网 price-adjustment route maps the `category` path parameter to a per-metal subdomain through SUB_DOMAIN_MAP (keys: copper, alu, zn, sn, pb, ni). Any value that is not a key yields undefined, and the handler throws a generic Error with the Chinese message '未知的金属类型' ('unknown metal type') before issuing the request. Note the codes are short forms (alu, not aluminium).","triggerScenarios":"Requesting `/ccmn/price-adjustment/<x>` where <x> is not one of copper, alu, zn, sn, pb, ni — e.g. `/ccmn/price-adjustment/iron` or `/ccmn/price-adjustment/aluminium`.","commonSituations":"Supplying the full English name (aluminium, tin, lead, nickel) or the Chinese metal name instead of the documented short code; typos; copy-pasting a path segment from the source site that differs from the route code.","solutions":["Use one of the six supported codes: copper, alu, zn, sn, pb, ni.","Cross-check the value against the route's `parameters.category.options` list declared in the route config.","For a new metal, confirm ccmn has a dedicated subdomain and add a SUB_DOMAIN_MAP entry."],"exampleFix":"// before\n//   /ccmn/price-adjustment/aluminium\n// after\n//   /ccmn/price-adjustment/alu","handlingStrategy":"type-guard","validationCode":"const KNOWN_METALS = new Set(['copper', 'alu', 'zn', 'sn', 'pb', 'ni']);\nfunction isKnownMetal(category: string): boolean {\n  return KNOWN_METALS.has(category);\n}","typeGuard":"function isKnownMetal(category: string): category is keyof typeof SUB_DOMAIN_MAP {\n  return Object.prototype.hasOwnProperty.call(SUB_DOMAIN_MAP, category);\n}","tryCatchPattern":null,"preventionTips":["Drive the category from the route's declared `options` list so invalid values never reach the handler.","Throw InvalidParameterError (not generic Error) so the framework returns a proper 400."],"tags":["validation","enum","i18n"],"backgroundTag":null,"analyzedSha":"bed535e0879dc71c5aff6f1e7bd1ac21ede40115","analyzedAt":"2026-08-12T19:29:35.364Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}