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

View File

@@ -207,11 +207,11 @@ function captureBasicData(el) {
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 };
}
@@ -219,7 +219,7 @@ function captureBasicData(el) {
function basicBuildSelector(el) {
if (el.id) {
const sel = '#' + CSS.escape(el.id);
try { if (document.querySelectorAll(sel).length === 1) return sel; } catch {}
try { if (document.querySelectorAll(sel).length === 1) return sel; } catch (e) { if (!(e instanceof TypeError) && !(e instanceof DOMException)) throw e; }
}
const parts = [];
let current = el;