From 1fb1d20beedce3f5b249a3f003c3e1b0f4e45416 Mon Sep 17 00:00:00 2001 From: Emmanuel Raviart Date: Mon, 20 May 2024 14:33:57 +0200 Subject: [PATCH] Improve handling of fetch errors --- src/scripts/download_dole_html.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/scripts/download_dole_html.ts b/src/scripts/download_dole_html.ts index b18ca02..de8c090 100644 --- a/src/scripts/download_dole_html.ts +++ b/src/scripts/download_dole_html.ts @@ -153,6 +153,7 @@ async function fetchHtmlPage(url: string): Promise { const response = await fetch(url) if (!response.ok) { if (retriesCount === 0) { + console.warn(`Error while retrieving HTML page at ${url}`) console.warn(response.status, response.statusText) console.warn(JSON.stringify(response.headers, null, 2)) console.warn(await response.text()) @@ -160,6 +161,7 @@ async function fetchHtmlPage(url: string): Promise { if (retriesCount < 10) { await sleep(30) console.info("Retrying…") + continue } else { throw new Error(`Retrieval of HTML page at <${url}> failed`) } @@ -167,6 +169,7 @@ async function fetchHtmlPage(url: string): Promise { const html = await response.text() if (html.includes("Request unsuccessful. Incapsula incident ID:")) { if (retriesCount === 0) { + console.warn(`Error while retrieving HTML page at ${url}`) console.warn(response.status, response.statusText) console.warn(JSON.stringify(response.headers, null, 2)) console.warn(html) @@ -174,6 +177,7 @@ async function fetchHtmlPage(url: string): Promise { if (retriesCount < 10) { await sleep(30) console.info("Retrying…") + continue } else { throw new Error(`Retrieval of HTML page at <${url}> failed`) }