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

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: Remove unnecessary check. Created 8 years, 3 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 | « no previous file | utils/pub/io.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: utils/pub/hosted_source.dart
diff --git a/utils/pub/hosted_source.dart b/utils/pub/hosted_source.dart
index 97b8d17786e258be8fe971231205b0e1544de3d8..5e48153260e195d4206ea1c48b11a65d650c5729 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,17 @@ 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));
+ }).transformException((ex) {
+ if (ex is HttpException && ex.statusCode == 404) {
+ throw 'Could not find package "${parsed.first}" on ${parsed.last}.';
+ }
+
+ // Otherwise re-throw the original exception.
+ throw ex;
});
}
« no previous file with comments | « no previous file | utils/pub/io.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698