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

Unified Diff: utils/pub/source.dart

Issue 14253005: Migrate pub away from throwing strings. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Code review changes Created 7 years, 8 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 | « utils/pub/pubspec.dart ('k') | utils/pub/source_registry.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: utils/pub/source.dart
diff --git a/utils/pub/source.dart b/utils/pub/source.dart
index b5e5d53132c02cc9a883bdd966684630ee046325..ba2afa400c4b40ba4b2d28ad5d324b506f331624 100644
--- a/utils/pub/source.dart
+++ b/utils/pub/source.dart
@@ -80,7 +80,9 @@ abstract class Source {
/// pubspec. There is no default implementation for non-cached sources; they
/// must implement it manually.
Future<Pubspec> describe(PackageId id) {
- if (!shouldCache) throw "Source $name must implement describe(id).";
+ if (!shouldCache) {
+ throw new UnimplementedError("Source $name must implement describe(id).");
+ }
return installToSystemCache(id).then((package) => package.pubspec);
}
@@ -99,8 +101,8 @@ abstract class Source {
/// This doesn't need to be implemented if [installToSystemCache] is
/// implemented.
Future<bool> install(PackageId id, String path) {
- throw "Either install or installToSystemCache must be implemented for "
- "source $name.";
+ throw new UnimplementedError("Either install or installToSystemCache must "
+ "be implemented for source $name.");
}
/// Installs the package identified by [id] to the system cache. This is only
@@ -122,7 +124,7 @@ abstract class Source {
ensureDir(path.dirname(packageDir));
return install(id, packageDir);
}).then((found) {
- if (!found) throw 'Package $id not found.';
+ if (!found) fail('Package $id not found.');
return new Package.load(id.name, packageDir, systemCache.sources);
});
}
@@ -210,7 +212,9 @@ abstract class Source {
/// Returns the [Package]s that have been installed in the system cache.
List<Package> getCachedPackages() {
- if (shouldCache) throw "Source $name must implement this.";
+ if (shouldCache) {
+ throw new UnimplementedError("Source $name must implement this.");
+ }
}
/// Returns the source's name.
« no previous file with comments | « utils/pub/pubspec.dart ('k') | utils/pub/source_registry.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698