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

Unified Diff: utils/pub/utils.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/source_registry.dart ('k') | utils/tests/pub/command_line_config.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: utils/pub/utils.dart
diff --git a/utils/pub/utils.dart b/utils/pub/utils.dart
index 5e80e5701c37b52df45d4ff7dcc0fc435da5dd27..e21eaab75c3cc935ff07cb2da063f9202364197c 100644
--- a/utils/pub/utils.dart
+++ b/utils/pub/utils.dart
@@ -7,6 +7,7 @@ library utils;
import 'dart:async';
import 'dart:crypto';
+import 'dart:io';
import 'dart:isolate';
import 'dart:uri';
@@ -358,3 +359,34 @@ Future awaitObject(object) {
return map;
});
}
+
+/// An exception class for exceptions that are intended to be seen by the user.
+/// These exceptions won't have any debugging information printed when they're
+/// thrown.
+class UserFacingException implements Exception {
+ final String message;
+
+ UserFacingException(this.message);
+}
+
+/// Throw a [UserFacingException] with [message].
+void fail(String message) {
+ throw new UserFacingException(message);
+}
+
+/// Returns whether [error] is a user-facing error object. This includes both
+/// [UserFacingException] and any dart:io errors.
+bool isUserFacingException(error) {
+ return error is UserFacingException ||
+ // TODO(nweiz): clean up this branch when issue 9955 is fixed.
+ error is DirectoryIOException ||
+ error is FileIOException ||
+ error is HttpException ||
+ error is HttpParserException ||
+ error is LinkIOException ||
+ error is MimeParserException ||
+ error is OSError ||
+ error is ProcessException ||
+ error is SocketIOException ||
+ error is WebSocketException;
+}
« no previous file with comments | « utils/pub/source_registry.dart ('k') | utils/tests/pub/command_line_config.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698