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

Unified Diff: pkg/compiler/lib/src/diagnostics/invariant.dart

Issue 2982783003: Use failedAt in more places (Closed)
Patch Set: Created 3 years, 5 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 | « pkg/compiler/lib/src/compiler.dart ('k') | pkg/compiler/lib/src/elements/modelx.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/diagnostics/invariant.dart
diff --git a/pkg/compiler/lib/src/diagnostics/invariant.dart b/pkg/compiler/lib/src/diagnostics/invariant.dart
index 28a6b427eee2d7fcc5af3faf10fbf7684b3dd933..bdfc7f23acbf00e9c960f8f41441760bbebeb651 100644
--- a/pkg/compiler/lib/src/diagnostics/invariant.dart
+++ b/pkg/compiler/lib/src/diagnostics/invariant.dart
@@ -35,17 +35,22 @@ assertDebugMode(String message) {
///
/// [spannable] must be non-null and will be used to provide positional
/// information in the generated error message.
-bool failedAt(Spannable spannable, [var message]) {
+///
+/// This method can also be used to throw a [SpannableAssertionFailure] outside
+/// an assert:
+///
+/// failedAt(position, message);
+///
+/// or, if the enclosing function requires a result or control flow:
+///
+/// throw failedAt(position, message);
+///
+bool failedAt(Spannable spannable, [String message]) {
// TODO(johnniwinther): Use [spannable] and [message] to provide better
// information on assertion errors.
if (spannable == null) {
- throw new SpannableAssertionFailure(
- CURRENT_ELEMENT_SPANNABLE,
- 'Spannable was null for failedInvariant. '
- 'Use CURRENT_ELEMENT_SPANNABLE.');
- }
- if (message is Function) {
- message = message();
+ throw new SpannableAssertionFailure(CURRENT_ELEMENT_SPANNABLE,
+ 'Spannable was null for failedAt. Use CURRENT_ELEMENT_SPANNABLE.');
}
throw new SpannableAssertionFailure(spannable, message);
}
« no previous file with comments | « pkg/compiler/lib/src/compiler.dart ('k') | pkg/compiler/lib/src/elements/modelx.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698