Commit c57ff654a8c9a637c6b7842e46cb621585484e81
fix error catching + display
mix irving committed on 8/31/2017, 4:55:11 AMParent: b51d7758237b262870685f4987822ea751f33200
Files changed
app/async/catch-link-click.js | changed |
app/html/app.js | changed |
app/html/search-bar.js | changed |
app/html/error.js | deleted |
app/html/error.mcss | deleted |
app/page/errors.js | changed |
app/page/profile.js | changed |
app/page/errors.mcss | added |
router/sync/routes.js | changed |
app/async/catch-link-click.js | ||
---|---|---|
@@ -22,9 +22,9 @@ | ||
22 | 22 | } |
23 | 23 | if (!anchor) return true |
24 | 24 | |
25 | 25 | var href = anchor.getAttribute('href') |
26 | - if (!href) return | |
26 | + if (!href || href == '#') return | |
27 | 27 | |
28 | 28 | var url = Url.parse(href) |
29 | 29 | var opts = { |
30 | 30 | altKey: ev.altKey, |
app/html/app.js | ||
---|---|---|
@@ -5,11 +5,11 @@ | ||
5 | 5 | exports.gives = nest('app.html.app') |
6 | 6 | |
7 | 7 | exports.needs = nest({ |
8 | 8 | 'app.async.catchLinkClick': 'first', |
9 | - 'app.html.error': 'first', | |
10 | 9 | 'app.html.externalConfirm': 'first', |
11 | 10 | 'app.html.tabs': 'first', |
11 | + 'app.page.errors': 'first', | |
12 | 12 | 'app.sync.window': 'reduce', |
13 | 13 | 'app.sync.addPage': 'first', |
14 | 14 | 'app.sync.catchKeyboardShortcut': 'first', |
15 | 15 | 'router.sync.router': 'first', |
@@ -48,15 +48,14 @@ | ||
48 | 48 | } |
49 | 49 | }) |
50 | 50 | |
51 | 51 | // Catch errors |
52 | - // var { container: errorPage, content: errorList } = api.router.sync.router('/errors') | |
53 | - // window.addEventListener('error', ev => { | |
54 | - // if (!tabs.has('/errors')) tabs.add(errorPage, true) | |
52 | + var { container: errorPage, addError } = api.router.sync.router('/errors') | |
53 | + window.addEventListener('error', ev => { | |
54 | + if (!tabs.has('/errors')) tabs.add(errorPage, true) | |
55 | 55 | |
56 | - // const error = api.app.html.error(ev.error || ev) | |
57 | - // errorList.appendChild(error) | |
58 | - // }) | |
56 | + addError(ev.error || ev) | |
57 | + }) | |
59 | 58 | |
60 | 59 | return App |
61 | 60 | } |
62 | 61 | } |
app/html/search-bar.js | ||
---|---|---|
@@ -27,9 +27,9 @@ | ||
27 | 27 | case 13: // enter |
28 | 28 | var location = input.value.trim() |
29 | 29 | if (location[0] == '?') { |
30 | 30 | location = { page: 'search', query: location.substring(1) } |
31 | - } else if (!['@', '#', '%', '&'].includes(location[0])) { | |
31 | + } else if (!['@', '#', '%', '&', '/'].includes(location[0])) { | |
32 | 32 | location = { page: 'search', query: location } |
33 | 33 | } |
34 | 34 | |
35 | 35 | api.app.sync.goTo(location) |
app/html/error.js | ||
---|---|---|
@@ -1,15 +1,0 @@ | ||
1 | -const nest = require('depnest') | |
2 | -const { h } = require('mutant') | |
3 | - | |
4 | -exports.gives = nest('app.html.error') | |
5 | - | |
6 | -exports.create = function (api) { | |
7 | - return nest('app.html.error', error) | |
8 | - | |
9 | - function error (err) { | |
10 | - return h('Error', [ | |
11 | - h('header', err.message), | |
12 | - h('pre', err.stack) | |
13 | - ]) | |
14 | - } | |
15 | -} |
app/html/error.mcss | ||
---|---|---|
@@ -1,25 +1,0 @@ | ||
1 | -Error { | |
2 | - padding: 1rem | |
3 | - | |
4 | - header { | |
5 | - color: red | |
6 | - font-weight: 600 | |
7 | - } | |
8 | - | |
9 | - pre { | |
10 | - padding: 1rem | |
11 | - border: 1px gainsboro solid | |
12 | - } | |
13 | -} | |
14 | - | |
15 | -Scroller -errors { | |
16 | - div.wrapper { | |
17 | - width: initial | |
18 | - max-width: 100% | |
19 | - | |
20 | - section.content div { | |
21 | - border: none | |
22 | - } | |
23 | - } | |
24 | -} | |
25 | - |
app/page/errors.js | ||
---|---|---|
@@ -1,5 +1,6 @@ | ||
1 | 1 | const nest = require('depnest') |
2 | +const { h } = require('mutant') | |
2 | 3 | |
3 | 4 | exports.gives = nest('app.page.errors') |
4 | 5 | |
5 | 6 | exports.needs = nest({ |
@@ -11,11 +12,21 @@ | ||
11 | 12 | |
12 | 13 | function errorsPage (location) { |
13 | 14 | var { container, content } = api.app.html.scroller() |
14 | 15 | |
15 | - container.classList = ['-errors'] | |
16 | + container.title = '/errors' | |
17 | + container.classList = ['Errors'] | |
18 | + container.id = JSON.stringify(location) | |
19 | + // note this page needs an id assigned as it's not added by addPage | |
16 | 20 | |
17 | - // add a dummy entry in the list | |
21 | + function addError (err) { | |
22 | + const error = h('Error', [ | |
23 | + h('header', err.message), | |
24 | + h('pre', err.stack) | |
25 | + ]) | |
18 | 26 | |
19 | - return { container, content } | |
27 | + content.appendChild(error) | |
28 | + } | |
29 | + | |
30 | + return { container, addError } | |
20 | 31 | } |
21 | 32 | } |
app/page/profile.js | ||
---|---|---|
@@ -10,12 +10,10 @@ | ||
10 | 10 | 'app.page.profile': true |
11 | 11 | }) |
12 | 12 | |
13 | 13 | exports.needs = nest({ |
14 | - 'about': { | |
15 | - 'html.edit': 'first', | |
16 | - 'obs.name': 'first' | |
17 | - }, | |
14 | + 'about.html.edit': 'first', | |
15 | + 'about.obs.name': 'first', | |
18 | 16 | 'app.html.scroller': 'first', |
19 | 17 | 'app.sync.goTo': 'first', |
20 | 18 | 'contact.html.relationships': 'first', |
21 | 19 | 'keys.sync.id': 'first', |
@@ -61,9 +59,8 @@ | ||
61 | 59 | // pull.through(console.log.bind(console)), |
62 | 60 | Scroller(container, content, api.message.html.render, false, false) |
63 | 61 | ) |
64 | 62 | |
65 | - container.id = JSON.stringify(location) | |
66 | 63 | watch(api.about.obs.name(id), name => { container.title = '@' + name }) |
67 | 64 | return container |
68 | 65 | } |
69 | 66 | } |
app/page/errors.mcss | ||
---|---|---|
@@ -1,0 +1,25 @@ | ||
1 | +Errors { | |
2 | + div.wrapper { | |
3 | + width: initial | |
4 | + max-width: 100% | |
5 | + | |
6 | + section.content div { | |
7 | + border: none | |
8 | + } | |
9 | + } | |
10 | +} | |
11 | + | |
12 | +Error { | |
13 | + padding: 1rem | |
14 | + | |
15 | + header { | |
16 | + color: red | |
17 | + font-weight: 600 | |
18 | + } | |
19 | + | |
20 | + pre { | |
21 | + padding: 1rem | |
22 | + border: 1px gainsboro solid | |
23 | + } | |
24 | +} | |
25 | + |
router/sync/routes.js | ||
---|---|---|
@@ -28,9 +28,9 @@ | ||
28 | 28 | [ loc => loc.page === 'public', pages.public ], |
29 | 29 | [ loc => loc.page === 'private', pages.private ], |
30 | 30 | [ loc => loc.page === 'notifications', pages.notifications ], |
31 | 31 | [ loc => loc.page === 'errors', pages.errors ], |
32 | - [ loc => loc.page === 'profile', () => pages.profile({ id: myId }) ], | |
32 | + [ loc => loc.page === 'profile', () => pages.profile({ feed: myId }) ], | |
33 | 33 | [ loc => loc.page === 'search' && loc.query, pages.search ], |
34 | 34 | |
35 | 35 | [ loc => isBlob(loc.blob), pages.blob ], |
36 | 36 | [ loc => isPresent(loc.channel), pages.channel ], |
Built with git-ssb-web