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

Unified Diff: pkg/analyzer/lib/error/error.dart

Issue 2426583003: Improve error messages and add many corrections (Closed)
Patch Set: Created 4 years, 2 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
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/dart/error/syntactic_errors.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/error/error.dart
diff --git a/pkg/analyzer/lib/error/error.dart b/pkg/analyzer/lib/error/error.dart
index 648a447e14a7e82db07f889afbebbdcc9e45ed73..3f8fcbdf50051a3f0806a5359bbe9ab9442f2aa7 100644
--- a/pkg/analyzer/lib/error/error.dart
+++ b/pkg/analyzer/lib/error/error.dart
@@ -235,11 +235,59 @@ class AnalysisErrorWithProperties extends AnalysisError {
*
* Generally, we want to provide messages that consist of three sentences. From
* the user's perspective these sentences should explain:
+ *
* 1. what is wrong,
* 2. why is it wrong, and
* 3. how do I fix it.
+ *
* However, we combine the first two in the [message] and the last in the
* [correction].
+ *
+ * When composing messages (including correction messages) keep the following
+ * guidelines in mind.
+ *
+ * 1. The message should be a complete sentence starting with an uppercase
+ * letter, and ending with a period.
+ *
+ * 2. Reserved words and embedded identifiers should be in single quotes, so
+ * prefer double quotes for the complete message. For example,
+ * ```
+ * "The class '{0}' can't use 'super'."
+ * ```
+ * Notice that the word 'class' in the preceding message is not quoted as it
+ * refers to the concept 'class', not the reserved word. On the other hand,
+ * 'super' refers to the reserved word. Do not quote 'null' and numeric literals.
+ *
+ * 3. Do not try to compose messages, as it can make translating them hard.
+ *
+ * 4. Try to keep the error messages short, but informative.
+ *
+ * 5. Use simple words and terminology, assume the reader of the message doesn't
+ * have an advanced degree in math, and that English is not the reader's native
+ * language. Do not assume any formal computer science training. For example, do
+ * not use Latin abbreviations (prefer "that is" over "i.e.", and "for example"
+ * over "e.g."). Also avoid phrases such as "if and only if" and "iff"; that
+ * level of precision is unnecessary.
+ *
+ * 6. Prefer contractions when they are in common use, for example, prefer
+ * "can't" over "cannot". Using "cannot", "must not", "shall not", etc. is
+ * off-putting to people new to programming.
+ *
+ * 7. Use common terminology, preferably from the Dart Language Specification.
+ * This increases the user's chance of finding a good explanation on the web.
+ *
+ * 8. Do not try to be cute or funny. It is extremely frustrating to work on a
+ * product that crashes with a "tongue-in-cheek" message, especially if you did
+ * not want to use this product to begin with.
+ *
+ * 9. Do not lie, that is, do not write error messages containing phrases like
+ * "can't happen". If the user ever saw this message, it would be a lie. Prefer
+ * messages like: "Internal error: This function should not be called when 'x'
+ * is null.".
+ *
+ * 10. Prefer to not use the imperative tone. That is, the message should not
+ * sound accusing or like it is ordering the user around. The computer should
+ * describe the problem, not criticize the user for violating the specification.
*/
abstract class ErrorCode {
/**
@@ -277,7 +325,6 @@ abstract class ErrorCode {
CompileTimeErrorCode.BUILT_IN_IDENTIFIER_AS_TYPEDEF_NAME,
CompileTimeErrorCode.BUILT_IN_IDENTIFIER_AS_TYPE_PARAMETER_NAME,
CompileTimeErrorCode.CASE_EXPRESSION_TYPE_IMPLEMENTS_EQUALS,
- CompileTimeErrorCode.COMPILE_TIME_CONSTANT_RAISES_EXCEPTION,
CompileTimeErrorCode.CONFLICTING_GETTER_AND_METHOD,
CompileTimeErrorCode.CONFLICTING_METHOD_AND_GETTER,
CompileTimeErrorCode.CONFLICTING_CONSTRUCTOR_NAME_AND_FIELD,
@@ -499,7 +546,6 @@ abstract class ErrorCode {
StaticTypeWarningCode.ILLEGAL_ASYNC_GENERATOR_RETURN_TYPE,
StaticTypeWarningCode.ILLEGAL_ASYNC_RETURN_TYPE,
StaticTypeWarningCode.ILLEGAL_SYNC_GENERATOR_RETURN_TYPE,
- StaticTypeWarningCode.INACCESSIBLE_SETTER,
StaticTypeWarningCode.INCONSISTENT_METHOD_INHERITANCE,
StaticTypeWarningCode.INSTANCE_ACCESS_TO_STATIC_MEMBER,
StaticTypeWarningCode.INVALID_ASSIGNMENT,
@@ -662,7 +708,6 @@ abstract class ErrorCode {
ParserErrorCode.ABSTRACT_TYPEDEF,
ParserErrorCode.ANNOTATION_ON_ENUM_CONSTANT,
ParserErrorCode.ASYNC_KEYWORD_USED_AS_IDENTIFIER,
- ParserErrorCode.ASYNC_NOT_SUPPORTED,
ParserErrorCode.BREAK_OUTSIDE_OF_LOOP,
ParserErrorCode.CLASS_IN_CLASS,
ParserErrorCode.COLON_IN_PLACE_OF_IN,
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/dart/error/syntactic_errors.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698