{"record":{"id":"ab65dc73d0e20797","repo":"DIYgod/RSSHub","slug":"reserrortext","errorCode":null,"errorMessage":"resErrorText","messagePattern":"resErrorText","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"lib/routes/japanpost/track.tsx","lineNumber":50,"sourceCode":"\n    const list = $('.tableType01').eq(1).find('tr').slice(2);\n    const officeList = $('.tableType03').eq(0).find('tr').slice(1);\n    let officeItemList;\n\n    if (officeList.length) {\n        officeItemList = officeList.toArray().map((e) => {\n            const eTd = $(e).find('td');\n            return {\n                officeType: eTd.eq(0).text().trim(),\n                officeName: eTd.eq(1).html()!.trim(),\n                officeTel: eTd.eq(2).html()!.trim(),\n            };\n        });\n    }\n\n    if (!list.length) {\n        const resErrorText = $('.tableType01').eq(0).find('tr').eq(2).find('td').eq(1).text().trim();\n        throw new Error(resErrorText);\n    }\n\n    const listEven = utils.even(list);\n    const listOdd = utils.odd(list);\n\n    const packageType = $('.tableType01').eq(0).find('tr').eq(1).find('td').eq(1).text().trim();\n    const packageService = $('.tableType01').eq(0).find('tr').eq(1).find('td').eq(2).text().trim();\n    const serviceText = locale === 'ja' ? '付加サービス：' : 'Additional services: ';\n\n    let lastItemTimestamp;\n    let tz;\n\n    return {\n        title: `${baseTitle} ${reqCode} ${packageType}`,\n        link,\n        description: `${baseTitle} ${reqCode} ${packageType}`,\n        language: locale as Language,\n        icon: 'https://www.post.japanpost.jp/favicon.ico',","sourceCodeStart":32,"sourceCodeEnd":68,"githubUrl":"https://github.com/DIYgod/RSSHub/blob/bed535e0879dc71c5aff6f1e7bd1ac21ede40115/lib/routes/japanpost/track.tsx#L32-L68","documentation":"Thrown by the Japan Post tracking route when the parsed tracking-history table (.tableType01 eq(1)) has no rows. The route then scrapes the human-readable error message Japan Post shows on the page (from the first table, row 2, cell 1) and re-throws it verbatim. The error message is therefore dynamic — whatever Japan Post displays (e.g. 'お問い合わせの番号は...'), often in Japanese.","triggerScenarios":"Tracking number is mistyped, not yet registered in the system, has already completed delivery and aged out, or belongs to a service Japan Post's domestic tracker does not cover. Any case where the tracking page renders an error table instead of a history table.","commonSituations":"User submits a tracking number with extra spaces or wrong format. A package was just shipped and the tracking number is not yet active (typically a few hours delay). A non-JapanPost number (e.g. a USPS number) is submitted. The locale is set to 'en' but the error text is still in Japanese because Japan Post's error rendering is locale-inconsistent.","solutions":["Double-check the tracking number for typos and trim whitespace before submitting.","Wait a few hours and retry if the package was just shipped — the number may not be registered yet.","If the error text is in Japanese and unreadable, retry with locale=en in the route path.","In the route itself, fall back to a generic English message when the scraped resErrorText is empty."],"exampleFix":"// before\nif (!list.length) {\n    const resErrorText = $('.tableType01').eq(0).find('tr').eq(2).find('td').eq(1).text().trim();\n    throw new Error(resErrorText);\n}\n\n// after — guard against an empty scraped message\nif (!list.length) {\n    const resErrorText = $('.tableType01').eq(0).find('tr').eq(2).find('td').eq(1).text().trim();\n    throw new Error(resErrorText || `No tracking data found for ${reqCode}. The number may be invalid or not yet registered.`);\n}","handlingStrategy":"validation","validationCode":"// Validate tracking number format before calling Japan Post\nconst reqCode = ctx.req.param('reqCode');\nif (!/^[A-Za-z0-9]{10,25}$/.test(reqCode)) {\n    throw new InvalidParameterError(`Tracking number '${reqCode}' does not look valid (expected 10-25 alphanumeric chars).`);\n}","typeGuard":null,"tryCatchPattern":"try {\n    // ...fetch and parse\n    if (!list.length) {\n        const resErrorText = $('.tableType01').eq(0).find('tr').eq(2).find('td').eq(1).text().trim();\n        throw new Error(resErrorText || `No tracking data for ${reqCode}`);\n    }\n} catch (e) {\n    // Distinguish 'invalid number' from 'transient unavailable'\n    throw e;\n}","preventionTips":["Sanitize the tracking number (trim whitespace, uppercase alphabetic codes).","Retry after a few hours if a just-shipped package returns no data — registration lags.","Display the raw Japan Post error text to end users; it is authoritative.","Fall back to a generic English message if the scraped text is empty."],"tags":["scraping","tracking","dynamic-message","japanpost","external-error"],"backgroundTag":null,"analyzedSha":"bed535e0879dc71c5aff6f1e7bd1ac21ede40115","analyzedAt":"2026-08-12T19:29:35.364Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}