Better error message when FCC 499 search is down

FCC ColdFusion app returns 503 periodically. Show helpful message
suggesting FRN search instead of generic "Search failed".

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
justin 2026-05-22 00:39:38 -05:00
parent 7909f130c6
commit 33684a9152

View file

@ -1280,12 +1280,18 @@ router.get("/api/v1/fcc/cores-search", async (req, res) => {
});
if (!resp.ok) {
res.status(502).json({ error: `FCC search returned ${resp.status}` });
res.status(502).json({ error: `The FCC search system is temporarily unavailable (HTTP ${resp.status}). Try searching by FRN instead, or try again in a few minutes.` });
return;
}
const html = await resp.text();
// FCC sometimes returns 200 but with a maintenance/error page
if (html.includes("Service Unavailable") || (html.includes("503") && !html.includes("499results"))) {
res.status(502).json({ error: "The FCC search system is temporarily unavailable. Try searching by FRN instead, or try again in a few minutes." });
return;
}
// Parse the results table rows: <tr><th scope="row">834314</th> ... <td><A HREF="499detail.cfm?FilerNum=834314">Carrier One Inc.</a></td><td>DBA</td></tr>
const rowRegex = /<tr><th scope="row">(\d+)<\/th>\s*\n?\s*<td><A HREF="499detail\.cfm\?FilerNum=\d+">([^<]+)<\/a><\/td><td>([^<]*)<\/td><\/tr>/gi;
const results: { filer_id: string; legal_name: string; dba: string }[] = [];