Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(683)

Unified Diff: runtime/observatory/lib/src/elements/cpu_profile.dart

Issue 1120133002: Rework error handling in the service protocol and in Observatory. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: fix tests Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: runtime/observatory/lib/src/elements/cpu_profile.dart
diff --git a/runtime/observatory/lib/src/elements/cpu_profile.dart b/runtime/observatory/lib/src/elements/cpu_profile.dart
index 0da1ee5569e2bfa50c68e86c8d2cd02e3f84edf1..13e7c21e5ae673888add34fa7eecf07d26d1e0ea 100644
--- a/runtime/observatory/lib/src/elements/cpu_profile.dart
+++ b/runtime/observatory/lib/src/elements/cpu_profile.dart
@@ -465,11 +465,11 @@ class CpuProfileElement extends ObservatoryElement {
}
void isolateChanged(oldValue) {
- _getCpuProfile();
+ _getCpuProfile().catchError(app.handleException);
}
void tagSelectorChanged(oldValue) {
- _getCpuProfile();
+ _getCpuProfile().catchError(app.handleException);
}
void modeSelectorChanged(oldValue) {
@@ -480,11 +480,7 @@ class CpuProfileElement extends ObservatoryElement {
_updateView();
}
- void clear(var done) {
- _clearCpuProfile().whenComplete(done);
- }
-
- Future _clearCpuProfile() {
+ Future clearCpuProfile() {
profile.clear();
if (isolate == null) {
return new Future.value(null);
@@ -495,8 +491,8 @@ class CpuProfileElement extends ObservatoryElement {
});
}
- void refresh(var done) {
- _getCpuProfile().whenComplete(done);
+ Future refresh() {
+ return _getCpuProfile();
}
_onFetchStarted() {
@@ -523,7 +519,7 @@ class CpuProfileElement extends ObservatoryElement {
state = 'Loaded';
}
- Future _getCpuProfile() {
+ Future _getCpuProfile() async {
profile.clear();
if (functionTree != null) {
functionTree.clear();
@@ -537,24 +533,30 @@ class CpuProfileElement extends ObservatoryElement {
return new Future.value(null);
}
_onFetchStarted();
- return isolate.invokeRpc('getCpuProfile', { 'tags': tagSelector })
- .then((response) async {
+ try {
+ var params = { 'tags': tagSelector };
+ var response = await isolate.invokeRpc('getCpuProfile', params);
_onFetchFinished();
await _onLoadStarted();
- try {
- profile.load(isolate, response);
- _onLoadFinished();
- _updateView();
- } catch (e, st) {
+ profile.load(isolate, response);
+ _onLoadFinished();
+ _updateView();
+ } catch (e, st) {
+ bool handled = false;
+ if (e is ServerRpcException) {
+ ServerRpcException se = e;
+ if (se.code == ServerRpcException.kProfilingDisabled) {
+ state = 'Disabled';
+ handled = true;
+ }
+ }
+ if (!handled) {
state = 'Exception';
exception = e;
stackTrace = st;
+ rethrow;
}
- }).catchError((e, st) {
- state = 'Exception';
- exception = e;
- stackTrace = st;
- });
+ }
}
void _updateView() {
@@ -794,7 +796,9 @@ class CpuProfileTableElement extends ObservatoryElement {
}
isolateChanged() {
- _getCpuProfile().whenComplete(checkParameters);
+ _getCpuProfile()
+ .catchError(app.handleException)
+ .whenComplete(checkParameters);
}
checkParameters() {
@@ -813,12 +817,8 @@ class CpuProfileTableElement extends ObservatoryElement {
_updateFunctionTreeView();
}
- void refresh(var done) {
- _getCpuProfile().whenComplete(done);
- }
-
- void clear(var done) {
- _clearCpuProfile().whenComplete(done);
+ Future refresh() {
+ return _getCpuProfile();
}
_onFetchStarted() {
@@ -844,7 +844,7 @@ class CpuProfileTableElement extends ObservatoryElement {
state = 'Loaded';
}
- Future _clearCpuProfile() {
+ Future clearCpuProfile() {
profile.clear();
_clearView();
if (isolate == null) {
@@ -856,32 +856,38 @@ class CpuProfileTableElement extends ObservatoryElement {
});
}
- Future _getCpuProfile() {
+ Future _getCpuProfile() async {
profile.clear();
_clearView();
if (isolate == null) {
return new Future.value(null);
}
_onFetchStarted();
- return isolate.invokeRpc('getCpuProfile', { 'tags': 'None' })
- .then((response) {
+ try {
+ var params = { 'tags': 'None' };
+ var response = await isolate.invokeRpc('getCpuProfile', params);
_onFetchFinished();
_onLoadStarted();
- try {
- profile.load(isolate, response);
- profile.buildFunctionCallerAndCallees();
- _onLoadFinished();
- _updateView();
- } catch (e, st) {
+ profile.load(isolate, response);
+ profile.buildFunctionCallerAndCallees();
+ _onLoadFinished();
+ _updateView();
+ } catch (e, st) {
+ bool handled = false;
+ if (e is ServerRpcException) {
+ ServerRpcException se = e;
+ if (se.code == ServerRpcException.kProfilingDisabled) {
+ state = 'Disabled';
+ handled = true;
+ }
+ }
+ if (!handled) {
state = 'Exception';
exception = e;
stackTrace = st;
+ rethrow;
}
- }).catchError((e, st) {
- state = 'Exception';
- exception = e;
- stackTrace = st;
- });
+ }
}
_clearView() {
« no previous file with comments | « runtime/observatory/lib/src/elements/context_view.dart ('k') | runtime/observatory/lib/src/elements/cpu_profile.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698