OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 library error_view_element; | 5 library error_view_element; |
6 | 6 |
7 import 'dart:html'; | 7 import 'dart:html'; |
8 import 'dart:async'; | 8 import 'dart:async'; |
9 import 'package:observatory/models.dart' as M; | 9 import 'package:observatory/models.dart' as M; |
10 import 'package:observatory/src/elements/helpers/nav_bar.dart'; | 10 import 'package:observatory/src/elements/helpers/nav_bar.dart'; |
11 import 'package:observatory/src/elements/helpers/rendering_scheduler.dart'; | 11 import 'package:observatory/src/elements/helpers/rendering_scheduler.dart'; |
12 import 'package:observatory/src/elements/helpers/tag.dart'; | 12 import 'package:observatory/src/elements/helpers/tag.dart'; |
13 import 'package:observatory/src/elements/nav/notify.dart'; | 13 import 'package:observatory/src/elements/nav/notify.dart'; |
14 import 'package:observatory/src/elements/nav/top_menu.dart'; | 14 import 'package:observatory/src/elements/nav/top_menu.dart'; |
15 import 'package:observatory/src/elements/view_footer.dart'; | 15 import 'package:observatory/src/elements/view_footer.dart'; |
16 | 16 |
17 class ErrorViewElement extends HtmlElement implements Renderable{ | 17 class ErrorViewElement extends HtmlElement implements Renderable { |
18 static const tag = const Tag<ErrorViewElement>('error-view', | 18 static const tag = const Tag<ErrorViewElement>('error-view', |
19 dependencies: const [NavTopMenuElement.tag, | 19 dependencies: const [ |
20 NavNotifyElement.tag, | 20 NavTopMenuElement.tag, |
21 ViewFooterElement.tag]); | 21 NavNotifyElement.tag, |
| 22 ViewFooterElement.tag |
| 23 ]); |
22 | 24 |
23 RenderingScheduler _r; | 25 RenderingScheduler _r; |
24 | 26 |
25 Stream<RenderedEvent<ErrorViewElement>> get onRendered => | 27 Stream<RenderedEvent<ErrorViewElement>> get onRendered => _r.onRendered; |
26 _r.onRendered; | |
27 | 28 |
28 M.Error _error; | 29 M.Error _error; |
29 M.NotificationRepository _notifications; | 30 M.NotificationRepository _notifications; |
30 | 31 |
31 M.Error get error => _error; | 32 M.Error get error => _error; |
32 | 33 |
33 factory ErrorViewElement(M.NotificationRepository notifications, | 34 factory ErrorViewElement( |
34 M.Error error, | 35 M.NotificationRepository notifications, M.Error error, |
35 {RenderingQueue queue}) { | 36 {RenderingQueue queue}) { |
36 assert(error != null); | 37 assert(error != null); |
37 assert(notifications != null); | 38 assert(notifications != null); |
38 ErrorViewElement e = document.createElement(tag.name); | 39 ErrorViewElement e = document.createElement(tag.name); |
39 e._r = new RenderingScheduler(e, queue: queue); | 40 e._r = new RenderingScheduler(e, queue: queue); |
40 e._error = error; | 41 e._error = error; |
41 e._notifications = notifications; | 42 e._notifications = notifications; |
42 return e; | 43 return e; |
43 } | 44 } |
44 | 45 |
45 ErrorViewElement.created() : super.created(); | 46 ErrorViewElement.created() : super.created(); |
(...skipping 16 matching lines...) Expand all Loading... |
62 navBar([ | 63 navBar([ |
63 new NavTopMenuElement(queue: _r.queue), | 64 new NavTopMenuElement(queue: _r.queue), |
64 new NavNotifyElement(_notifications, queue: _r.queue) | 65 new NavNotifyElement(_notifications, queue: _r.queue) |
65 ]), | 66 ]), |
66 new DivElement() | 67 new DivElement() |
67 ..classes = ['content-centered'] | 68 ..classes = ['content-centered'] |
68 ..children = [ | 69 ..children = [ |
69 new HeadingElement.h1() | 70 new HeadingElement.h1() |
70 ..text = 'Error: ${_kindToString(_error.kind)}', | 71 ..text = 'Error: ${_kindToString(_error.kind)}', |
71 new BRElement(), | 72 new BRElement(), |
72 new DivElement()..classes = ['well'] | 73 new DivElement() |
73 ..children = [ | 74 ..classes = ['well'] |
74 new PreElement()..text = error.message | 75 ..children = [new PreElement()..text = error.message] |
75 ] | |
76 ], | 76 ], |
77 new ViewFooterElement(queue: _r.queue) | 77 new ViewFooterElement(queue: _r.queue) |
78 ]; | 78 ]; |
79 } | 79 } |
80 | 80 |
81 static String _kindToString(M.ErrorKind kind) { | 81 static String _kindToString(M.ErrorKind kind) { |
82 switch(kind) { | 82 switch (kind) { |
83 case M.ErrorKind.unhandledException: | 83 case M.ErrorKind.unhandledException: |
84 return 'Unhandled Exception'; | 84 return 'Unhandled Exception'; |
85 case M.ErrorKind.languageError: | 85 case M.ErrorKind.languageError: |
86 return 'Language Error'; | 86 return 'Language Error'; |
87 case M.ErrorKind.internalError: | 87 case M.ErrorKind.internalError: |
88 return 'Internal Error'; | 88 return 'Internal Error'; |
89 case M.ErrorKind.terminationError: | 89 case M.ErrorKind.terminationError: |
90 return 'Termination Error'; | 90 return 'Termination Error'; |
91 } | 91 } |
92 throw new Exception('Unkown M.ErrorKind ($kind)'); | 92 throw new Exception('Unkown M.ErrorKind ($kind)'); |
93 } | 93 } |
94 } | 94 } |
OLD | NEW |