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

Unified Diff: pkg/front_end/lib/src/fasta/errors.dart

Issue 2706053002: Implement --fatal=errors. (Closed)
Patch Set: Address comments. Created 3 years, 10 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/front_end/lib/src/fasta/errors.dart
diff --git a/pkg/front_end/lib/src/fasta/errors.dart b/pkg/front_end/lib/src/fasta/errors.dart
index fb5d27105f0b2de44ad38d0651309deedde9a9c1..a053a610a26a961da402757eb3aeb928c105ef28 100644
--- a/pkg/front_end/lib/src/fasta/errors.dart
+++ b/pkg/front_end/lib/src/fasta/errors.dart
@@ -20,7 +20,10 @@ import 'dart:io' show
import 'colors.dart' show
red;
-import 'messages.dart' as messages;
+import 'messages.dart' show
+ errorsAreFatal,
+ format,
+ isVerbose;
const String defaultServerAddress = "http://127.0.0.1:59410/";
@@ -44,8 +47,7 @@ dynamic internalError(Object error, [Uri uri, int charOffset = -1]) {
if (uri == null && charOffset == -1) {
throw error;
} else {
- throw messages.format(
- uri, charOffset, "Internal error: ${safeToString(error)}");
+ throw format(uri, charOffset, "Internal error: ${safeToString(error)}");
}
}
@@ -62,6 +64,20 @@ dynamic inputError(Uri uri, int charOffset, Object error) {
throw new InputError(uri, charOffset, error);
}
+String printUnexpected(Uri uri, int charOffset, String message) {
+ if (errorsAreFatal) {
+ if (isVerbose) print(StackTrace.current);
+ throw new InputError(uri, charOffset, message);
+ }
+ message = formatUnexpected(uri, charOffset, message);
+ print(message);
+ return message;
+}
+
+String formatUnexpected(Uri uri, int charOffset, String message) {
+ return format(uri, charOffset, colorError("Error: $message"));
+}
+
String colorError(String message) {
// TODO(ahe): Colors need to be optional. Doesn't work well in Emacs or on
// Windows.
@@ -80,10 +96,7 @@ class InputError {
toString() => "InputError: $error";
- String format() {
- return messages.format(
- uri, charOffset, colorError("Error: ${safeToString(error)}"));
- }
+ String format() => formatUnexpected(uri, charOffset, safeToString(error));
}
class Crash {
« no previous file with comments | « pkg/front_end/lib/src/fasta/compiler_command_line.dart ('k') | pkg/front_end/lib/src/fasta/kernel/body_builder.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698