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

Side by Side Diff: pkg/fletchc/lib/src/diagnostic.dart

Issue 1271183002: Document throwInternalError (Closed) Base URL: git@github.com:dart-lang/fletch.git@master
Patch Set: Created 5 years, 4 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2015, the Fletch project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, the Fletch project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE.md file. 3 // BSD-style license that can be found in the LICENSE.md file.
4 4
5 library fletchc.diagnostic; 5 library fletchc.diagnostic;
6 6
7 import 'messages.dart' show 7 import 'messages.dart' show
8 DiagnosticKind, 8 DiagnosticKind,
9 getMessage; 9 getMessage;
10 10
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 Target target = value; 117 Target target = value;
118 // TODO(ahe): Improve this conversion. 118 // TODO(ahe): Improve this conversion.
119 stringValue = target.toString(); 119 stringValue = target.toString();
120 break; 120 break;
121 } 121 }
122 result[parameter.name] = stringValue; 122 result[parameter.name] = stringValue;
123 }); 123 });
124 return result; 124 return result;
125 } 125 }
126 126
127 /// Throw an internal error that will be recorded as a compiler crash.
128 ///
129 /// In general, assume, no matter how unlikely, that [message] may be read by a
130 /// user (that is, a developer using Fletch). For this reason, try to:
131 ///
132 /// * Avoid phrases that can be interpreted as blaming the user (all error
133 /// messages should state what is wrong, in a way that doesn't assign blame).
134 ///
135 /// * Avoid being cute or funny (there's nothing more frustrating than being
136 /// affected by a bug and see a cute or funny message, especially if it
137 /// happens a lot).
138 ///
139 /// * Avoid phrases like "unreachable", "can't happen", "shouldn't happen",
140 /// "shouldn't be called", simply because it is wrong: it did happen. In most
141 /// cases a factual message would be "unimplemented", "unhandled case",
142 /// etc. Remember that the stacktrace will pinpoint the exact location of the
143 /// problem, so no need to repeat a method name.
127 void throwInternalError(String message) { 144 void throwInternalError(String message) {
128 throw new InputError( 145 throw new InputError(
129 DiagnosticKind.internalError, 146 DiagnosticKind.internalError,
130 <DiagnosticParameter, dynamic>{DiagnosticParameter.message: message}); 147 <DiagnosticParameter, dynamic>{DiagnosticParameter.message: message});
131 } 148 }
132 149
133 void throwFatalError( 150 void throwFatalError(
134 DiagnosticKind kind, 151 DiagnosticKind kind,
135 {String message, 152 {String message,
136 ResolvedVerb verb, 153 ResolvedVerb verb,
(...skipping 16 matching lines...) Expand all
153 arguments[DiagnosticParameter.target] = target; 170 arguments[DiagnosticParameter.target] = target;
154 } 171 }
155 if (address != null) { 172 if (address != null) {
156 arguments[DiagnosticParameter.address] = address; 173 arguments[DiagnosticParameter.address] = address;
157 } 174 }
158 if (userInput != null) { 175 if (userInput != null) {
159 arguments[DiagnosticParameter.userInput] = address; 176 arguments[DiagnosticParameter.userInput] = address;
160 } 177 }
161 throw new InputError(kind, arguments); 178 throw new InputError(kind, arguments);
162 } 179 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698