Index: editor/util/plugins/com.google.dart.java2dart/resources/java_engine.dart |
diff --git a/editor/util/plugins/com.google.dart.java2dart/resources/java_engine.dart b/editor/util/plugins/com.google.dart.java2dart/resources/java_engine.dart |
index 497f6cf4da87790ab937bd9e085f4465fe91aa70..37cbe39866ba63829dd89647a5329ca53aa52c14 100644 |
--- a/editor/util/plugins/com.google.dart.java2dart/resources/java_engine.dart |
+++ b/editor/util/plugins/com.google.dart.java2dart/resources/java_engine.dart |
@@ -202,3 +202,88 @@ class UUID { |
String toString() => id; |
static UUID randomUUID() => new UUID((__nextId).toString()); |
} |
+ |
+ |
+/** |
+ * Instances of the class `AnalysisException` represent an exception that |
+ * occurred during the analysis of one or more sources. |
+ */ |
+class AnalysisException implements Exception { |
+ /** |
+ * The message that explains why the exception occurred. |
+ */ |
+ final String message; |
+ |
+ /** |
+ * The exception that caused this exception, or `null` if this exception was |
+ * not caused by another exception. |
+ */ |
+ final CaughtException cause; |
+ |
+ /** |
+ * Initialize a newly created exception to have the given [message] and |
+ * [cause]. |
+ */ |
+ AnalysisException([this.message = 'Exception', this.cause = null]); |
+} |
+ |
+ |
+/** |
+ * Instances of the class `CaughtException` represent an exception that was |
+ * caught and has an associated stack trace. |
+ */ |
+class CaughtException implements Exception { |
+ /** |
+ * The exception that was caught. |
+ */ |
+ final Exception exception; |
+ |
+ /** |
+ * The stack trace associated with the exception. |
+ */ |
+ StackTrace stackTrace; |
+ |
+ /** |
+ * Initialize a newly created caught exception to have the given [exception] |
+ * and [stackTrace]. |
+ */ |
+ CaughtException(this.exception, stackTrace) { |
+ if (stackTrace == null) { |
+ try { |
+ throw this; |
+ } catch (_, st) { |
+ stackTrace = st; |
+ } |
+ } |
+ this.stackTrace = stackTrace; |
+ } |
+ |
+ @override |
+ String toString() { |
+ StringBuffer buffer = new StringBuffer(); |
+ _writeOn(buffer); |
+ return buffer.toString(); |
+ } |
+ |
+ /** |
+ * Write a textual representation of the caught exception and its associated |
+ * stack trace. |
+ */ |
+ void _writeOn(StringBuffer buffer) { |
+ if (exception is AnalysisException) { |
+ AnalysisException analysisException = exception; |
+ buffer.writeln(analysisException.message); |
+ if (stackTrace != null) { |
+ buffer.writeln(stackTrace.toString()); |
+ } |
+ CaughtException cause = analysisException.cause; |
+ if (cause != null) { |
+ buffer.write('Caused by '); |
+ cause._writeOn(buffer); |
+ } |
+ } else { |
+ buffer.writeln(exception.toString()); |
+ buffer.writeln(stackTrace.toString()); |
+ } |
+ } |
+} |