mirror of
https://github.com/garrytan/gstack.git
synced 2026-07-11 10:23:44 +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:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user