Chromium Code Reviews| Index: pkg/front_end/lib/src/fasta/command_line_reporting.dart |
| diff --git a/pkg/front_end/lib/src/fasta/command_line_reporting.dart b/pkg/front_end/lib/src/fasta/command_line_reporting.dart |
| index 37cd08d555b36e6645bca5e9a9a19ccc73ffbd49..18bf1a93bd4b3b7629efab58f5a4681aaf9a465f 100644 |
| --- a/pkg/front_end/lib/src/fasta/command_line_reporting.dart |
| +++ b/pkg/front_end/lib/src/fasta/command_line_reporting.dart |
| @@ -34,16 +34,9 @@ const bool hideWarnings = false; |
| /// command-line tool. This includes source snippets and different colors based |
| /// on [severity]. |
| /// |
| -/// It is a assumed that a formatted message is reported to a user, so |
| -/// [exitCode] is also set depending on the value of |
| -/// `CompilerContext.current.options.setExitCodeOnProblem`. |
| -/// |
| /// This is shared implementation used by methods below, and isn't intended to |
| /// be called directly. |
| String formatInternal(Message message, Severity severity, Uri uri, int offset) { |
| - if (CompilerContext.current.options.setExitCodeOnProblem) { |
| - exitCode = 1; |
| - } |
| String text = |
| "${severityName(severity, capitalized: true)}: ${message.message}"; |
| if (message.tip != null) { |
| @@ -139,8 +132,20 @@ String severityName(Severity severity, {bool capitalized: false}) { |
| return unhandled("$severity", "severityName", -1, null); |
| } |
| +/// Print a formatted message and throw when errors are treated as fatal. |
| +/// Also set [exitCode] depending on the value of |
| +/// `CompilerContext.current.options.setExitCodeOnProblem`. |
| void _printAndThrowIfFatal( |
| String text, Severity severity, Uri uri, int charOffset) { |
| + // I believe we should only set it if we are reporting something, if we are |
| + // formatting to embed the error in the program, then we probably don't want |
| + // to do it in format. |
| + // Note: I also want to limit dependencies to dart:io for when we use the FE |
| + // outside of the VM. This default reporting is likely not going to be used in |
| + // that context, but the default formatter is. |
| + if (CompilerContext.current.options.setExitCodeOnProblem) { |
|
Siggi Cherem (dart-lang)
2017/07/18 00:11:07
moved here because I believe we'd like to use `for
ahe
2017/07/18 16:54:37
I think this makes sense.
|
| + exitCode = 1; |
| + } |
| print(text); |
| if (isFatal(severity)) { |
| if (isVerbose) print(StackTrace.current); |