mirror of
https://github.com/garrytan/gstack.git
synced 2026-08-17 19:47:14 +02:00
refactor: selective catches in Chrome extension files
Convert empty catches and error-swallowing patterns across inspector.js, content.js, background.js, and sidepanel.js. DOM catches filter TypeError/DOMException, chrome API catches filter Extension context invalidated, network catches filter Failed to fetch. Unexpected errors now propagate. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
b8c4e703c6
commit
5f9246ac23
+12
-6
@@ -451,7 +451,8 @@ async function pollChat() {
|
||||
// Show/hide stop button based on agent status
|
||||
updateStopButton(data.agentStatus === 'processing');
|
||||
} catch (err) {
|
||||
console.error('[gstack sidebar] Chat poll error:', err.message);
|
||||
if (!err?.message?.includes('Failed to fetch') && !err?.message?.includes('The operation was aborted')) throw err;
|
||||
console.debug('[gstack sidebar] Chat poll skipped (server unreachable)');
|
||||
} finally {
|
||||
pollInProgress = false;
|
||||
}
|
||||
@@ -529,7 +530,8 @@ async function stopAgent() {
|
||||
const resp = await fetch(`${serverUrl}/sidebar-agent/stop`, { method: 'POST', headers: authHeaders() });
|
||||
if (!resp.ok) console.warn(`[gstack sidebar] Stop agent failed: ${resp.status}`);
|
||||
} catch (err) {
|
||||
console.error('[gstack sidebar] Stop agent error:', err.message);
|
||||
if (!err?.message?.includes('Failed to fetch')) throw err;
|
||||
console.debug('[gstack sidebar] Stop agent skipped (server unreachable)');
|
||||
}
|
||||
// Immediately clean up UI
|
||||
const thinking = document.getElementById('agent-thinking');
|
||||
@@ -598,7 +600,8 @@ async function pollTabs() {
|
||||
|
||||
renderTabBar(data.tabs);
|
||||
} catch (err) {
|
||||
console.error('[gstack sidebar] Tab poll error:', err.message);
|
||||
if (!err?.message?.includes('Failed to fetch') && !err?.message?.includes('The operation was aborted')) throw err;
|
||||
console.debug('[gstack sidebar] Tab poll skipped (server unreachable)');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -646,7 +649,8 @@ async function switchBrowserTab(tabId) {
|
||||
switchChatTab(tabId);
|
||||
pollTabs();
|
||||
} catch (err) {
|
||||
console.error('[gstack sidebar] Failed to switch browser tab:', err.message);
|
||||
if (!err?.message?.includes('Failed to fetch')) throw err;
|
||||
console.debug('[gstack sidebar] Tab switch skipped (server unreachable)');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -658,7 +662,8 @@ document.getElementById('clear-chat').addEventListener('click', async () => {
|
||||
const resp = await fetch(`${serverUrl}/sidebar-chat/clear`, { method: 'POST', headers: authHeaders() });
|
||||
if (!resp.ok) console.warn(`[gstack sidebar] Clear chat failed: ${resp.status}`);
|
||||
} catch (err) {
|
||||
console.error('[gstack sidebar] Clear chat error:', err.message);
|
||||
if (!err?.message?.includes('Failed to fetch')) throw err;
|
||||
console.debug('[gstack sidebar] Clear chat skipped (server unreachable)');
|
||||
}
|
||||
// Reset local state
|
||||
chatLineCount = 0;
|
||||
@@ -690,7 +695,8 @@ document.getElementById('chat-cookies-btn').addEventListener('click', async () =
|
||||
body: JSON.stringify({ command: 'goto', args: [`${serverUrl}/cookie-picker`] }),
|
||||
});
|
||||
} catch (err) {
|
||||
console.error('[gstack sidebar] Failed to open cookie picker:', err.message);
|
||||
if (!err?.message?.includes('Failed to fetch')) throw err;
|
||||
console.debug('[gstack sidebar] Cookie picker skipped (server unreachable)');
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user