From ccdae1abeae3fbbd1416114c83f800e8d093a7b2 Mon Sep 17 00:00:00 2001 From: katspaugh Date: Sun, 26 Nov 2023 15:23:40 +0100 Subject: [PATCH] Fix: catch 400/500 errors --- src/fetcher.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/fetcher.ts b/src/fetcher.ts index ce4e3670a..db7435d7d 100644 --- a/src/fetcher.ts +++ b/src/fetcher.ts @@ -40,6 +40,10 @@ async function fetchBlob( // Fetch the resource const response = await fetch(url, requestInit) + if (!response.ok) { + throw new Error(`Failed to fetch ${url}: ${response.status} (${response.statusText})`) + } + // Read the data to track progress watchProgress(response.clone(), progressCallback)