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; |
+} |