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

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

Issue 2704753002: Implement line and column numbers. (Closed)
Patch Set: Change message. 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 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)}"));
}
}
« no previous file with comments | « pkg/front_end/lib/src/fasta/dill/dill_target.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