Skip to content

Commit 30d469a

Browse files
committed
Add better error logging for inventory sync debugging
1 parent 84df496 commit 30d469a

1 file changed

Lines changed: 13 additions & 2 deletions

File tree

src/inventorySync.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,21 @@
7070
});
7171

7272
if (!response.ok) {
73-
throw new Error(`Steam API returned ${response.status}. Make sure you're logged into Steam.`);
73+
const text = await response.text();
74+
this.log(`❌ Steam API error ${response.status}:`, text.substring(0, 200));
75+
throw new Error(`Steam API returned ${response.status}. Make sure you're logged into Steam and your inventory is public.`);
7476
}
7577

76-
const data = await response.json();
78+
const text = await response.text();
79+
this.log('📋 Response preview:', text.substring(0, 200));
80+
81+
let data;
82+
try {
83+
data = JSON.parse(text);
84+
} catch (parseError) {
85+
this.log('❌ Failed to parse JSON. Response was:', text.substring(0, 500));
86+
throw new Error('Steam returned HTML instead of JSON. Check:\n1. You are logged into Steam\n2. Your inventory is set to Public\n3. Try refreshing the page');
87+
}
7788

7889
if (!data.assets || !data.descriptions) {
7990
throw new Error('Invalid inventory response from Steam');

0 commit comments

Comments
 (0)