Files: 55335207126eb15c3a0f1834ffb8bbcbd32658a8 / app / sync / initialise / error-catcher.js
756 bytesRaw
1 | const nest = require('depnest') |
2 | |
3 | exports.gives = nest('app.sync.initialise') |
4 | |
5 | exports.needs = nest({ |
6 | 'router.sync.router': 'first', |
7 | 'app.html.tabs': 'first' |
8 | }) |
9 | |
10 | exports.create = function (api) { |
11 | return nest('app.sync.initialise', errorCatcher) |
12 | |
13 | function errorCatcher () { |
14 | const tabs = api.app.html.tabs() |
15 | |
16 | var { container: errorPage, addError } = api.router.sync.router('/errors') |
17 | window.addEventListener('error', ev => { |
18 | // HACK: Fix for ResizeObserver errors that are probably benign. |
19 | if (ev.message && ev.message.startsWith('ResizeObserver')) { |
20 | console.error('ResizeObserver (caught)') |
21 | return |
22 | } |
23 | |
24 | if (!tabs.has('/errors')) tabs.add(errorPage, true) |
25 | |
26 | addError(ev.error || ev) |
27 | }) |
28 | } |
29 | } |
30 |
Built with git-ssb-web