{"record":{"id":"350f6d6f3c8d2b80","repo":"DIYgod/RSSHub","slug":"nanjing-cannot-find-page","errorCode":null,"errorMessage":"Nanjing, Cannot find page","messagePattern":"Nanjing, Cannot find page","errorType":"exception","errorClass":null,"httpStatus":503,"severity":"warning","filePath":"lib/routes-deprecated/gov/city/nanjing/index.js","lineNumber":27,"sourceCode":"    switch (category) {\n        case 'news':\n            url = `${homePage}/njxx/`;\n            break;\n        case 'department':\n            url = `${homePage}/bmdt/`;\n            break;\n        case 'district':\n            url = `${homePage}/gqdt/`;\n            break;\n        case 'livelihood':\n            url = `${homePage}/mszx/`;\n            break;\n        default:\n            logger.error('URL pattern not matched');\n    }\n\n    if (url === '') {\n        throw new Error('Nanjing, Cannot find page');\n    }\n\n    const responseData = await getContent(url, TOTAL_PAGE);\n    return responseData;\n};\n","sourceCodeStart":9,"sourceCodeEnd":33,"githubUrl":"https://github.com/DIYgod/RSSHub/blob/bed535e0879dc71c5aff6f1e7bd1ac21ede40115/lib/routes-deprecated/gov/city/nanjing/index.js#L9-L33","documentation":"Thrown by the Nanjing government route helper (deprecated) when the category does not match any switch case. The switch default only logs 'URL pattern not matched' and leaves url as ''; a subsequent `if (url === '')` guard then throws 'Nanjing, Cannot find page'. Valid cases are news, department, district, livelihood.","triggerScenarios":"Calling the helper with a category string outside {news, department, district, livelihood}. The default branch leaves url empty and the post-switch check throws.","commonSituations":"Caller passes a slug valid for another city's route, or an upstream route forwards an unsupported category. The two-stage (log then throw) design can mask the real cause in logs.","solutions":["Pass one of: news, department, district, livelihood.","Check the calling route's namespace/parameters to confirm which category values it forwards to this helper.","If you need a new category, add a switch case with the correct homePage path segment instead of bypassing the check."],"exampleFix":"// before\nurl = `${homePage}/unknown/`;  // no matching case\n// after\ncase 'news': url = `${homePage}/njxx/`; break;","handlingStrategy":"validation","validationCode":"const VALID = ['news', 'department', 'district', 'livelihood'];\nif (!VALID.includes(category)) throw new Error(`Invalid Nanjing category. Valid: ${VALID.join(', ')}`);","typeGuard":"const isNanjingCategory = (v: string): v is 'news' | 'department' | 'district' | 'livelihood' =>\n  ['news', 'department', 'district', 'livelihood'].includes(v);","tryCatchPattern":"try { await getContent(homePage, category); }\ncatch (e) { if (/Cannot find page/.test(e.message)) return fallbackFeed(); else throw e; }","preventionTips":["The empty-string sentinel is brittle — prefer an explicit unknown branch.","Log the offending category, not just 'URL pattern not matched'."],"tags":["rsshub","parameter-validation","deprecated-route","government","control-flow"],"backgroundTag":null,"analyzedSha":"bed535e0879dc71c5aff6f1e7bd1ac21ede40115","analyzedAt":"2026-08-12T19:29:35.364Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}