| 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 077f1609ba19867c24fb8d1581b9735e1b732830..fb5d27105f0b2de44ad38d0651309deedde9a9c1 100644
|
| --- a/pkg/front_end/lib/src/fasta/errors.dart
|
| +++ b/pkg/front_end/lib/src/fasta/errors.dart
|
| @@ -20,8 +20,7 @@ import 'dart:io' show
|
| import 'colors.dart' show
|
| red;
|
|
|
| -import 'util/relativize.dart' show
|
| - relativizeUri;
|
| +import 'messages.dart' as messages;
|
|
|
| const String defaultServerAddress = "http://127.0.0.1:59410/";
|
|
|
| @@ -41,8 +40,13 @@ Uri firstSourceUri;
|
| /// error: " and a short description that may help a developer debug the issue.
|
| /// This method should be called instead of using `throw`, as this allows us to
|
| /// ensure that there are no throws anywhere in the codebase.
|
| -dynamic internalError(Object error) {
|
| - throw error;
|
| +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)}");
|
| + }
|
| }
|
|
|
| /// Used to report an error in input.
|
| @@ -58,6 +62,12 @@ dynamic inputError(Uri uri, int charOffset, Object error) {
|
| throw new InputError(uri, charOffset, error);
|
| }
|
|
|
| +String colorError(String message) {
|
| + // TODO(ahe): Colors need to be optional. Doesn't work well in Emacs or on
|
| + // Windows.
|
| + return red(message);
|
| +}
|
| +
|
| class InputError {
|
| final Uri uri;
|
|
|
| @@ -71,15 +81,8 @@ class InputError {
|
| toString() => "InputError: $error";
|
|
|
| String format() {
|
| - // TODO(ahe): Colors need to be optional. Doesn't work well in Emacs or on
|
| - // Windows.
|
| - String message = red("Error: ${safeToString(error)}");
|
| - if (uri != null) {
|
| - String position = charOffset == -1 ? "" : "$charOffset:";
|
| - return "${relativizeUri(uri)}:$position $message";
|
| - } else {
|
| - return message;
|
| - }
|
| + return messages.format(
|
| + uri, charOffset, colorError("Error: ${safeToString(error)}"));
|
| }
|
| }
|
|
|
|
|