| Index: runtime/observatory/lib/src/app/application.dart
|
| diff --git a/runtime/observatory/lib/src/app/application.dart b/runtime/observatory/lib/src/app/application.dart
|
| index 0f37816c879ae7ce10e3f64ca9bb380eda6fad5a..ef74096fb64be8e836795d833d03ae55a61d0de0 100644
|
| --- a/runtime/observatory/lib/src/app/application.dart
|
| +++ b/runtime/observatory/lib/src/app/application.dart
|
| @@ -4,6 +4,15 @@
|
|
|
| part of app;
|
|
|
| +class Notification {
|
| + Notification.fromEvent(this.event);
|
| + Notification.fromException(this.exception, this.stacktrace);
|
| +
|
| + ServiceEvent event;
|
| + var exception;
|
| + var stacktrace;
|
| +}
|
| +
|
| /// The observatory application. Instances of this are created and owned
|
| /// by the observatory_application custom element.
|
| class ObservatoryApplication extends Observable {
|
| @@ -39,12 +48,12 @@ class ObservatoryApplication extends Observable {
|
| // This disconnect event occured *after* a new VM was installed.
|
| return;
|
| }
|
| - notifications.add(new ServiceEvent.connectionClosed(reason));
|
| + notifications.add(
|
| + new Notification.fromEvent(
|
| + new ServiceEvent.connectionClosed(reason)));
|
| });
|
|
|
| - vm.errors.stream.listen(_onError);
|
| vm.events.stream.listen(_onEvent);
|
| - vm.exceptions.stream.listen(_onException);
|
| }
|
| _vm = vm;
|
| }
|
| @@ -54,8 +63,8 @@ class ObservatoryApplication extends Observable {
|
| TraceViewElement _traceView = null;
|
|
|
| @reflectable ServiceObject lastErrorOrException;
|
| - @observable ObservableList<ServiceEvent> notifications =
|
| - new ObservableList<ServiceEvent>();
|
| + @observable ObservableList<Notification> notifications =
|
| + new ObservableList<Notification>();
|
|
|
| void _initOnce() {
|
| assert(app == null);
|
| @@ -67,17 +76,11 @@ class ObservatoryApplication extends Observable {
|
| }
|
|
|
| void removePauseEvents(Isolate isolate) {
|
| - bool isPauseEvent(var event) {
|
| - return (event.eventType == ServiceEvent.kPauseStart ||
|
| - event.eventType == ServiceEvent.kPauseExit ||
|
| - event.eventType == ServiceEvent.kPauseBreakpoint ||
|
| - event.eventType == ServiceEvent.kPauseInterrupted ||
|
| - event.eventType == ServiceEvent.kPauseException);
|
| - }
|
| -
|
| - notifications.removeWhere((oldEvent) {
|
| - return (oldEvent.isolate == isolate &&
|
| - isPauseEvent(oldEvent));
|
| + notifications.removeWhere((notification) {
|
| + var event = notification.event;
|
| + return (event != null &&
|
| + event.isolate == isolate &&
|
| + event.isPauseEvent);
|
| });
|
| }
|
|
|
| @@ -104,11 +107,11 @@ class ObservatoryApplication extends Observable {
|
| case ServiceEvent.kPauseInterrupted:
|
| case ServiceEvent.kPauseException:
|
| removePauseEvents(event.isolate);
|
| - notifications.add(event);
|
| + notifications.add(new Notification.fromEvent(event));
|
| break;
|
|
|
| case ServiceEvent.kInspect:
|
| - notifications.add(event);
|
| + notifications.add(new Notification.fromEvent(event));
|
| break;
|
|
|
| default:
|
| @@ -137,22 +140,6 @@ class ObservatoryApplication extends Observable {
|
| _pageRegistry.add(new ErrorPage(this));
|
| }
|
|
|
| - void _onError(ServiceError error) {
|
| - lastErrorOrException = error;
|
| - _visit(Uri.parse('error/'), null);
|
| - }
|
| -
|
| - void _onException(ServiceException exception) {
|
| - lastErrorOrException = exception;
|
| - if (exception.kind == 'NetworkException') {
|
| - // Got a network exception, visit the vm-connect page.
|
| - this.vm = null;
|
| - locationManager.go(locationManager.makeLink('/vm-connect'));
|
| - } else {
|
| - _visit(Uri.parse('error/'), {});
|
| - }
|
| - }
|
| -
|
| void _visit(Uri uri, Map internalArguments) {
|
| if (internalArguments['trace'] != null) {
|
| var traceArg = internalArguments['trace'];
|
| @@ -218,8 +205,10 @@ class ObservatoryApplication extends Observable {
|
| }
|
|
|
| void _removeDisconnectEvents() {
|
| - notifications.removeWhere((oldEvent) {
|
| - return (oldEvent.eventType == ServiceEvent.kConnectionClosed);
|
| + notifications.removeWhere((notification) {
|
| + var event = notification.event;
|
| + return (event != null &&
|
| + event.eventType == ServiceEvent.kConnectionClosed);
|
| });
|
| }
|
|
|
| @@ -227,4 +216,10 @@ class ObservatoryApplication extends Observable {
|
| this.vm = new FakeVM(crashDump['result']);
|
| app.locationManager.go('#/vm');
|
| }
|
| +
|
| + void handleException(e, st) {
|
| + // TODO(turnidge): Report this failure via analytics.
|
| + Logger.root.warning('Caught exception: ${e}\n${st}');
|
| + notifications.add(new Notification.fromException(e, st));
|
| + }
|
| }
|
|
|