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:
Garry Tan
2026-04-09 04:54:32 -10:00
parent b8c4e703c6
commit 5f9246ac23
4 changed files with 37 additions and 22 deletions
+8 -6
View File
@@ -159,7 +159,8 @@
function isUnique(selector) {
try {
return document.querySelectorAll(selector).length === 1;
} catch {
} catch (e) {
if (!(e instanceof TypeError) && !(e instanceof DOMException)) throw e;
return false;
}
}
@@ -244,11 +245,11 @@
source: sheet.href || 'inline',
});
}
} catch { /* skip rules that can't be matched */ }
} catch (e) { if (!(e instanceof TypeError) && !(e instanceof DOMException)) throw e; }
}
} catch { /* cross-origin sheet — silently skip */ }
} catch (e) { if (!(e instanceof DOMException)) throw e; }
}
} catch { /* CSSOM not available */ }
} catch (e) { if (!(e instanceof TypeError) && !(e instanceof DOMException)) throw e; }
return { computedStyles, boxModel, matchedRules };
}
@@ -290,7 +291,7 @@
try {
frameInfo.frameSrc = window.location.href;
frameInfo.frameName = window.name || null;
} catch { /* cross-origin frame */ }
} catch (e) { if (!(e instanceof DOMException)) throw e; }
}
chrome.runtime.sendMessage({
@@ -347,7 +348,8 @@
function findElement(selector) {
try {
return document.querySelector(selector);
} catch {
} catch (e) {
if (!(e instanceof TypeError) && !(e instanceof DOMException)) throw e;
return null;
}
}