()
| 86 | } |
| 87 | |
| 88 | export 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 | } |
no test coverage detected