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

Unified Diff: pkg/analyzer/lib/src/generated/java_engine.dart

Issue 2328043002: Move exception support to its own library (Closed)
Patch Set: Created 4 years, 3 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
Index: pkg/analyzer/lib/src/generated/java_engine.dart
diff --git a/pkg/analyzer/lib/src/generated/java_engine.dart b/pkg/analyzer/lib/src/generated/java_engine.dart
index 0190ddd64877830a70ebf2d4fa1ba52345ea8422..784fcb171a2456486dac7b0922b45a09ea166675 100644
--- a/pkg/analyzer/lib/src/generated/java_engine.dart
+++ b/pkg/analyzer/lib/src/generated/java_engine.dart
@@ -7,107 +7,13 @@ library analyzer.src.generated.java_engine;
import 'package:analyzer/src/generated/interner.dart';
import 'package:analyzer/src/generated/java_core.dart';
+export 'package:analyzer/exception/exception.dart';
+
/**
* A predicate is a one-argument function that returns a boolean value.
*/
typedef bool Predicate<E>(E argument);
-/**
- * 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]);
-
- String toString() {
- StringBuffer buffer = new StringBuffer();
- buffer.write("AnalysisException: ");
- buffer.writeln(message);
- if (cause != null) {
- buffer.write('Caused by ');
- cause._writeOn(buffer);
- }
- return buffer.toString();
- }
-}
-
-/**
- * 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 Object 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());
- if (stackTrace != null) {
- buffer.writeln(stackTrace.toString());
- }
- }
- }
-}
-
class FileNameUtilities {
static String getExtension(String fileName) {
if (fileName == null) {
« no previous file with comments | « pkg/analyzer/lib/src/generated/incremental_resolver.dart ('k') | pkg/analyzer/lib/src/generated/package.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698