git ssb

16+

Dominic / patchbay



Commit 03511a5a91763463c215e71fcb1df1b39e97b43f

fix and extract error tab!

mix irving committed on 2/10/2017, 5:24:18 AM
Parent: 10a6e10b5c3d8204fc1eca07af3083614c9d9db5

Files changed

modules_core/app.jschanged
modules_core/app.mcsschanged
modules_core/index.jschanged
modules_core/tabs.jschanged
modules_core/error.jsadded
modules_core/error.mcssadded
modules_core/app.jsView
@@ -27,9 +27,10 @@
2727
2828 window.onhashchange = () => view.set(getView())
2929 document.body.appendChild(screen)
3030
31- window.addEventListener('error', window.onError = displayError)
31 + // tabs (another core module) currently handles this
32 + // window.addEventListener('error', window.onError = displayError)
3233
3334 return screen
3435 }
3536
@@ -38,21 +39,21 @@
3839 return api.screen_view(view)
3940 }
4041 }
4142
42-function displayError (e) {
43- document.body.querySelector('.\\.content').appendChild(
44- h('div.page', [
45- h('Error', { title: e.message }, [
46- h('h1', e.message),
47- h('big', [
48- h('code', e.filename + ':' + e.lineno)
49- ]),
50- h('pre', e.error
51- ? (e.error.stack || e.error.toString())
52- : e.toString()
53- )
54- ])
55- ])
56- )
57-}
43 +// function displayError (e) {
44 +// document.body.querySelector('.\\.content').appendChild(
45 +// h('div.page', [
46 +// h('Error', { title: e.message }, [
47 +// h('h1', e.message),
48 +// h('big', [
49 +// h('code', e.filename + ':' + e.lineno)
50 +// ]),
51 +// h('pre', e.error
52 +// ? (e.error.stack || e.error.toString())
53 +// : e.toString()
54 +// )
55 +// ])
56 +// ])
57 +// )
58 +// }
5859
modules_core/app.mcssView
@@ -10,20 +10,5 @@
1010
1111 }
1212
1313
14-Error {
15- padding: 1rem
1614
17- h1 {
18- color: red
19- }
20-
21- big {
22- }
23-
24- pre {
25- padding: 1rem
26- border: 1px gainsboro solid
27- }
28-}
29-
modules_core/index.jsView
@@ -2,8 +2,9 @@
22 'app': require('./app'),
33 'blob-url': require('./blob-url'),
44 'crypto': require('./crypto'),
55 'external-confirm': require('./external-confirm'),
6 + 'error': require('./error'),
67 'file-input': require('./file-input'),
78 'menu': require('./menu'),
89 'names': require('./names'),
910 'tabs': require('./tabs'),
modules_core/tabs.jsView
@@ -10,8 +10,9 @@
1010 return el
1111 }
1212
1313 exports.needs = {
14 + build_error: 'first',
1415 build_scroller: 'first',
1516 screen_view: 'first',
1617 search_box: 'first',
1718 menu: 'first',
@@ -173,27 +174,28 @@
173174 })
174175
175176 // errors tab
176177 var {
177- container: errors,
178 + container: errorsScroller,
178179 content: errorsContent
179180 } = api.build_scroller()
180181
181- // remove loader error handler
182- if (window.onError) {
183- window.removeEventListener('error', window.onError)
184- delete window.onError
185- }
182 + errorsScroller.id = '/errors'
183 + errorsScroller.classList.add('-errors')
186184
185 + // remove loader error handler (currently disabled)
186 + // if (window.onError) {
187 + // window.removeEventListener('error', window.onError)
188 + // delete window.onError
189 + // }
190 +
187191 // put errors in a tab
188192 window.addEventListener('error', ev => {
189193 const err = ev.error || ev
190- if(!tabs.has('errors'))
191- tabs.add(errors, false)
192- const el = h('div.message', [
193- h('strong', err.message),
194- h('pre', err.stack)
195- ])
194 + if(!tabs.has('/errors'))
195 + tabs.add(errorsScroller, false)
196 +
197 + const el = api.build_error(err)
196198 if (errorsContent.firstChild)
197199 errorsContent.insertBefore(el, errorsContent.firstChild)
198200 else
199201 errorsContent.appendChild(el)
modules_core/error.jsView
@@ -1,0 +1,23 @@
1 +const fs = require('fs')
2 +const h = require('../h')
3 +
4 +exports.gives = {
5 + build_error: true,
6 + mcss: true
7 +}
8 +
9 +exports.create = function (api) {
10 + return {
11 + build_error,
12 + mcss: () => fs.readFileSync(__filename.replace(/js$/, 'mcss'), 'utf8')
13 + }
14 +
15 + function build_error (err) {
16 + return h('Error', [
17 + h('header', err.message),
18 + h('pre', err.stack)
19 + ])
20 + }
21 +
22 +}
23 +
modules_core/error.mcssView
@@ -1,0 +1,25 @@
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 +

Built with git-ssb-web