git ssb

16+

Dominic / patchbay



Commit c57ff654a8c9a637c6b7842e46cb621585484e81

fix error catching + display

mix irving committed on 8/31/2017, 4:55:11 AM
Parent: b51d7758237b262870685f4987822ea751f33200

Files changed

app/async/catch-link-click.jschanged
app/html/app.jschanged
app/html/search-bar.jschanged
app/html/error.jsdeleted
app/html/error.mcssdeleted
app/page/errors.jschanged
app/page/profile.jschanged
app/page/errors.mcssadded
router/sync/routes.jschanged
app/async/catch-link-click.jsView
@@ -22,9 +22,9 @@
app/html/app.jsView
@@ -5,11 +5,11 @@
55 exports.gives = nest('app.html.app')
66
77 exports.needs = nest({
88 'app.async.catchLinkClick': 'first',
9- 'app.html.error': 'first',
109 'app.html.externalConfirm': 'first',
1110 'app.html.tabs': 'first',
11+ 'app.page.errors': 'first',
1212 'app.sync.window': 'reduce',
1313 'app.sync.addPage': 'first',
1414 'app.sync.catchKeyboardShortcut': 'first',
1515 'router.sync.router': 'first',
@@ -48,15 +48,14 @@
4848 }
4949 })
5050
5151 // 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)
5555
56- // const error = api.app.html.error(ev.error || ev)
57- // errorList.appendChild(error)
58- // })
56+ addError(ev.error || ev)
57+ })
5958
6059 return App
6160 }
6261 }
app/html/search-bar.jsView
@@ -27,9 +27,9 @@
2727 case 13: // enter
2828 var location = input.value.trim()
2929 if (location[0] == '?') {
3030 location = { page: 'search', query: location.substring(1) }
31- } else if (!['@', '#', '%', '&'].includes(location[0])) {
31+ } else if (!['@', '#', '%', '&', '/'].includes(location[0])) {
3232 location = { page: 'search', query: location }
3333 }
3434
3535 api.app.sync.goTo(location)
app/html/error.jsView
@@ -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.mcssView
@@ -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.jsView
@@ -1,5 +1,6 @@
11 const nest = require('depnest')
2+const { h } = require('mutant')
23
34 exports.gives = nest('app.page.errors')
45
56 exports.needs = nest({
@@ -11,11 +12,21 @@
1112
1213 function errorsPage (location) {
1314 var { container, content } = api.app.html.scroller()
1415
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
1620
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+ ])
1826
19- return { container, content }
27+ content.appendChild(error)
28+ }
29+
30+ return { container, addError }
2031 }
2132 }
app/page/profile.jsView
@@ -10,12 +10,10 @@
1010 'app.page.profile': true
1111 })
1212
1313 exports.needs = nest({
14- 'about': {
15- 'html.edit': 'first',
16- 'obs.name': 'first'
17- },
14+ 'about.html.edit': 'first',
15+ 'about.obs.name': 'first',
1816 'app.html.scroller': 'first',
1917 'app.sync.goTo': 'first',
2018 'contact.html.relationships': 'first',
2119 'keys.sync.id': 'first',
@@ -61,9 +59,8 @@
6159 // pull.through(console.log.bind(console)),
6260 Scroller(container, content, api.message.html.render, false, false)
6361 )
6462
65- container.id = JSON.stringify(location)
6663 watch(api.about.obs.name(id), name => { container.title = '@' + name })
6764 return container
6865 }
6966 }
app/page/errors.mcssView
@@ -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.jsView
@@ -28,9 +28,9 @@
2828 [ loc => loc.page === 'public', pages.public ],
2929 [ loc => loc.page === 'private', pages.private ],
3030 [ loc => loc.page === 'notifications', pages.notifications ],
3131 [ loc => loc.page === 'errors', pages.errors ],
32- [ loc => loc.page === 'profile', () => pages.profile({ id: myId }) ],
32+ [ loc => loc.page === 'profile', () => pages.profile({ feed: myId }) ],
3333 [ loc => loc.page === 'search' && loc.query, pages.search ],
3434
3535 [ loc => isBlob(loc.blob), pages.blob ],
3636 [ loc => isPresent(loc.channel), pages.channel ],

Built with git-ssb-web