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

Unified Diff: runtime/bin/vmservice/client/lib/src/service/object.dart

Issue 265853011: Display an informative message when we hit the JSON decode bug. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 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
« no previous file with comments | « runtime/bin/vmservice/client/deployed/web/index_devtools.html_bootstrap.dart.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/vmservice/client/lib/src/service/object.dart
diff --git a/runtime/bin/vmservice/client/lib/src/service/object.dart b/runtime/bin/vmservice/client/lib/src/service/object.dart
index 1045df8359e936b1f1a37ffdc9234353fc4b6ed1..344a52cf25529f14b74760e9f1eca1b6e7e2d471 100644
--- a/runtime/bin/vmservice/client/lib/src/service/object.dart
+++ b/runtime/bin/vmservice/client/lib/src/service/object.dart
@@ -284,6 +284,28 @@ abstract class VM extends ServiceObjectOwner {
});
}
+ Future<ObservableMap> _processMap(ObservableMap map) {
+ // Verify that the top level response is a service map.
+ if (!_isServiceMap(map)) {
+ return new Future.error(
+ new ServiceObject._fromMap(this, toObservable({
+ 'type': 'ServiceException',
+ 'id': '',
+ 'kind': 'FormatException',
+ 'response': map,
+ 'message': 'Top level service responses must be service maps.',
+ })));
+ }
+ // Preemptively capture ServiceError and ServiceExceptions.
+ if (map['type'] == 'ServiceError') {
+ return new Future.error(new ServiceObject._fromMap(this, map));
+ } else if (map['type'] == 'ServiceException') {
+ return new Future.error(new ServiceObject._fromMap(this, map));
+ }
+ // map is now guaranteed to be a non-error/exception ServiceObject.
+ return new Future.value(map);
+ }
+
/// Gets [id] as an [ObservableMap] from the service directly. If
/// an error occurs, the future is completed as an error with a
/// ServiceError or ServiceException. Therefore any chained then() calls
@@ -292,34 +314,20 @@ abstract class VM extends ServiceObjectOwner {
return getString(id).then((response) {
try {
var map = toObservable(JSON.decode(response));
- // Verify that the top level response is a service map.
- if (!_isServiceMap(map)) {
- return new Future.error(
- new ServiceObject._fromMap(this, toObservable({
- 'type': 'ServiceException',
- 'id': '',
- 'kind': 'FormatException',
- 'response': map,
- 'message': 'Top level service responses must be service maps.',
- })));
- }
- // Preemptively capture ServiceError and ServiceExceptions.
- if (map['type'] == 'ServiceError') {
- return new Future.error(new ServiceObject._fromMap(this, map));
- } else if (map['type'] == 'ServiceException') {
- return new Future.error(new ServiceObject._fromMap(this, map));
- }
- // map is now guaranteed to be a non-error/exception ServiceObject.
- return map;
+ return _processMap(map);
} catch (e, st) {
- print(e);
- print(st);
+ // Two decode failures.
turnidge 2014/05/06 18:44:22 remove comment.
return new Future.error(
new ServiceObject._fromMap(this, toObservable({
'type': 'ServiceException',
'id': '',
'kind': 'DecodeException',
- 'response': response,
+ 'response':
+ 'This is likely a result of a known V8 bug. Although the '
+ 'the bug has been fixed the fix may not be in your Chrome'
+ ' version. For more information see dartbug.com/18385. '
+ 'Observatory is still functioning and you should try your'
+ ' action again.',
'message': 'Could not decode JSON: $e',
})));
}
« no previous file with comments | « runtime/bin/vmservice/client/deployed/web/index_devtools.html_bootstrap.dart.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698