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

Unified Diff: utils/pub/io.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/http.dart ('k') | utils/pub/pub.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: utils/pub/io.dart
diff --git a/utils/pub/io.dart b/utils/pub/io.dart
index ebc242dd6c6bdfc669661a1a8f32da6abd4dcc79..12121e7e1aedf6d9eeab76e951de2ec647a14c17 100644
--- a/utils/pub/io.dart
+++ b/utils/pub/io.dart
@@ -262,7 +262,9 @@ String relativeToPub(String target) {
var utilDir = path.dirname(scriptPath);
while (path.basename(utilDir) != 'utils' &&
path.basename(utilDir) != 'util') {
- if (path.basename(utilDir) == '') throw 'Could not find path to pub.';
+ if (path.basename(utilDir) == '') {
+ throw new Exception('Could not find path to pub.');
+ }
utilDir = path.dirname(utilDir);
}
@@ -544,8 +546,8 @@ Future<bool> extractTarGz(Stream<List<int>> stream, String destination) {
}).then((results) {
var exitCode = results[1];
if (exitCode != 0) {
- throw "Failed to extract .tar.gz stream to $destination (exit code "
- "$exitCode).";
+ throw new Exception("Failed to extract .tar.gz stream to $destination "
+ "(exit code $exitCode).");
}
log.fine("Extracted .tar.gz stream to $destination. Exit code $exitCode.");
});
@@ -576,25 +578,27 @@ Future<bool> _extractTarGzWindows(Stream<List<int>> stream,
return runProcess(command, ['e', 'data.tar.gz'], workingDir: tempDir);
}).then((result) {
if (result.exitCode != 0) {
- throw 'Could not un-gzip (exit code ${result.exitCode}). Error:\n'
+ throw new Exception('Could not un-gzip (exit code ${result.exitCode}). '
+ 'Error:\n'
'${result.stdout.join("\n")}\n'
- '${result.stderr.join("\n")}';
+ '${result.stderr.join("\n")}');
}
// Find the tar file we just created since we don't know its name.
var tarFile = listDir(tempDir).firstWhere(
(file) => path.extension(file) == '.tar',
orElse: () {
- throw 'The gzip file did not contain a tar file.';
+ throw new FormatException('The gzip file did not contain a tar file.');
});
// Untar the archive into the destination directory.
return runProcess(command, ['x', tarFile], workingDir: destination);
}).then((result) {
if (result.exitCode != 0) {
- throw 'Could not un-tar (exit code ${result.exitCode}). Error:\n'
+ throw new Exception('Could not un-tar (exit code ${result.exitCode}). '
+ 'Error:\n'
'${result.stdout.join("\n")}\n'
- '${result.stderr.join("\n")}';
+ '${result.stderr.join("\n")}');
}
return true;
});
@@ -618,7 +622,7 @@ ByteStream createTarGz(List contents, {baseDir}) {
contents = contents.map((entry) {
entry = path.absolute(entry);
if (!isBeneath(entry, baseDir)) {
- throw 'Entry $entry is not inside $baseDir.';
+ throw new ArgumentError('Entry $entry is not inside $baseDir.');
}
return path.relative(entry, from: baseDir);
}).toList();
« no previous file with comments | « utils/pub/http.dart ('k') | utils/pub/pub.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698