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

Unified Diff: utils/pub/hosted_source.dart

Issue 10917053: Show nicer errors on some server failures. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 4 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: utils/pub/hosted_source.dart
diff --git a/utils/pub/hosted_source.dart b/utils/pub/hosted_source.dart
index 97b8d17786e258be8fe971231205b0e1544de3d8..7acc840d3d8691dbe558d9e96ba7bef3a192f0d8 100644
--- a/utils/pub/hosted_source.dart
+++ b/utils/pub/hosted_source.dart
@@ -4,7 +4,6 @@
#library('hosted_source');
-#import('dart:io');
#import('dart:json');
#import('dart:uri');
#import('io.dart');
@@ -35,9 +34,14 @@ class HostedSource extends Source {
Future<List<Version>> getVersions(description) {
var parsed = _parseDescription(description);
var fullUrl = "${parsed.last}/packages/${parsed.first}.json";
- return consumeInputStream(httpGet(fullUrl)).transform((data) {
- var doc = JSON.parse(new String.fromCharCodes(data));
+
+ return httpGetString(fullUrl).transform((body) {
+ var doc = JSON.parse(body);
return doc['versions'].map((version) => new Version.parse(version));
+ }, (ex) {
+ if (ex is HttpException && ex.statusCode == 404) {
+ throw 'Could not find package "${parsed.first}" on ${parsed.last}.';
+ }
});
}
« no previous file with comments | « tests/corelib/future_test.dart ('k') | utils/pub/io.dart » ('j') | utils/pub/io.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698