From 47523d5a6ae48764ddb05383909d1b419009e576 Mon Sep 17 00:00:00 2001 From: rapture-party Date: Sun, 18 May 2025 13:38:23 -0400 Subject: [PATCH] fix: handle remote prices.tf error in background script --- src/background/background.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/background/background.ts b/src/background/background.ts index 1798bd1..86a1789 100644 --- a/src/background/background.ts +++ b/src/background/background.ts @@ -78,6 +78,9 @@ async function priceUsingPricesTF(token: string, sku: string, retries: number = throw new Error(`Cloudflare rate limit exceeded, stopping`) } } + if (!response.ok) { + throw new Error(`Pricing request for ${sku} failed with status code: ${response.status}`); + } const data = await response.json(); const prices = new PricesResponse(); prices.keys = data['sellKeys'] @@ -100,7 +103,8 @@ chrome.runtime.onMessage.addListener( priceUsingPricesTF(token, sku) .then((response) => sendResponse(response)) .catch(error => { - sendResponse(error); + console.error(`Received "${error}" error while pricing ${sku} using prices.tf`) + sendResponse(null); return false; }) }