Index: dart/sdk/lib/_internal/compiler/implementation/apiimpl.dart |
diff --git a/dart/sdk/lib/_internal/compiler/implementation/apiimpl.dart b/dart/sdk/lib/_internal/compiler/implementation/apiimpl.dart |
index abb492c7d4fa80274a3e7047fad46981b241b8d8..dc4d63740042c71faf28df038a19a805c78c4ce8 100644 |
--- a/dart/sdk/lib/_internal/compiler/implementation/apiimpl.dart |
+++ b/dart/sdk/lib/_internal/compiler/implementation/apiimpl.dart |
@@ -22,6 +22,7 @@ class Compiler extends leg.Compiler { |
List<String> options; |
bool mockableLibraryUsed = false; |
final Set<String> allowedLibraryCategories; |
+ final bool throwOnError; |
Compiler(this.provider, |
api.CompilerOutputProvider outputProvider, |
@@ -31,6 +32,7 @@ class Compiler extends leg.Compiler { |
List<String> options) |
: this.options = options, |
this.allowedLibraryCategories = getAllowedLibraryCategories(options), |
+ this.throwOnError = hasOption(options, '--throw-on-error'), |
super( |
tracer: new ssa.HTracer( |
ssa.GENERATE_SSA_TRACE ? outputProvider('dart', 'cfg') : null), |
@@ -273,9 +275,11 @@ class Compiler extends leg.Compiler { |
void reportDiagnostic(leg.SourceSpan span, String message, |
api.Diagnostic kind) { |
+ bool isFatal = false; |
if (identical(kind, api.Diagnostic.ERROR) |
|| identical(kind, api.Diagnostic.CRASH)) { |
compilationFailed = true; |
+ isFatal = true; |
} |
// [:span.uri:] might be [:null:] in case of a [Script] with no [uri]. For |
// instance in the [Types] constructor in typechecker.dart. |
@@ -285,6 +289,10 @@ class Compiler extends leg.Compiler { |
handler(translateUri(span.uri, null), span.begin, span.end, |
message, kind); |
} |
+ if (isFatal && throwOnError) { |
+ hasCrashed = true; |
kasperl
2013/06/28 10:26:50
Add a comment here? Rename flag to make it clear t
|
+ throw new AbortCompilation(message); |
+ } |
} |
bool get isMockCompilation { |
@@ -292,3 +300,9 @@ class Compiler extends leg.Compiler { |
&& (options.indexOf('--allow-mock-compilation') != -1); |
} |
} |
+ |
+class AbortCompilation { |
+ final message; |
+ AbortCompilation(this.message); |
+ toString() => 'Aborted due to --throw-on-error: $message'; |
+} |