MCPcopy
hub / github.com/refined-github/refined-github / catchErrors

Function catchErrors

source/helpers/errors.ts:88–107  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

86}
87
88export function catchErrors(): void {
89 globalThis.addEventListener('error', event => {
90 const {error} = event; // Access only once
91 // Don't use `assertError` or it'll loop
92 if (error) {
93 logError(error);
94 event.preventDefault();
95 }
96 });
97
98 globalThis.addEventListener('unhandledrejection', event => {
99 const error = event.reason; // Access only once
100 // Don't use `assertError` or it'll loop
101 // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing -- False positive: `||` is used on booleans, not nullish values
102 if (error?.stack.includes('-extension://') || error?.stack.includes('webkit-masked-url://')) {
103 logError(error);
104 event.preventDefault();
105 }
106 });
107}

Callers 1

Calls 2

logErrorFunction · 0.85
includesMethod · 0.80

Tested by

no test coverage detected