OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart 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 file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 part of dart.core; | 5 part of dart.core; |
6 | 6 |
7 /** | 7 /** |
8 * Error objects thrown in the case of a program failure. | 8 * Error objects thrown in the case of a program failure. |
9 * | 9 * |
10 * An `Error` object represents a program failure that the programmer | 10 * An `Error` object represents a program failure that the programmer |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 * A message is built by suffixing the [message] argument with | 152 * A message is built by suffixing the [message] argument with |
153 * the [name] argument (if provided) and the value. Example | 153 * the [name] argument (if provided) and the value. Example |
154 * | 154 * |
155 * "Invalid argument (foo): null" | 155 * "Invalid argument (foo): null" |
156 * | 156 * |
157 * The `name` should match the argument name of the function, but if | 157 * The `name` should match the argument name of the function, but if |
158 * the function is a method implementing an interface, and its argument | 158 * the function is a method implementing an interface, and its argument |
159 * names differ from the interface, it might be more useful to use the | 159 * names differ from the interface, it might be more useful to use the |
160 * interface method's argument name (or just rename arguments to match). | 160 * interface method's argument name (or just rename arguments to match). |
161 */ | 161 */ |
162 ArgumentError.value(value, | 162 ArgumentError.value(value, [this.name, this.message]) |
163 [String this.name, | |
164 String this.message]) | |
165 : invalidValue = value, | 163 : invalidValue = value, |
166 _hasValue = true; | 164 _hasValue = true; |
167 | 165 |
168 /** | 166 /** |
169 * Create an argument error for a `null` argument that must not be `null`. | 167 * Create an argument error for a `null` argument that must not be `null`. |
170 */ | 168 */ |
171 ArgumentError.notNull([this.name]) | 169 ArgumentError.notNull([this.name]) |
172 : _hasValue = false, | 170 : _hasValue = false, |
173 message = "Must not be null", | 171 message = "Must not be null", |
174 invalidValue = null; | 172 invalidValue = null; |
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
492 * | 490 * |
493 * This [Error] is thrown by unfinished code that hasn't yet implemented | 491 * This [Error] is thrown by unfinished code that hasn't yet implemented |
494 * all the features it needs. | 492 * all the features it needs. |
495 * | 493 * |
496 * If a class is not intending to implement the feature, it should throw | 494 * If a class is not intending to implement the feature, it should throw |
497 * an [UnsupportedError] instead. This error is only intended for | 495 * an [UnsupportedError] instead. This error is only intended for |
498 * use during development. | 496 * use during development. |
499 */ | 497 */ |
500 class UnimplementedError extends Error implements UnsupportedError { | 498 class UnimplementedError extends Error implements UnsupportedError { |
501 final String message; | 499 final String message; |
502 UnimplementedError([String this.message]); | 500 UnimplementedError([this.message]); |
503 String toString() => (this.message != null | 501 String toString() => (this.message != null |
504 ? "UnimplementedError: $message" | 502 ? "UnimplementedError: $message" |
505 : "UnimplementedError"); | 503 : "UnimplementedError"); |
506 } | 504 } |
507 | 505 |
508 | 506 |
509 /** | 507 /** |
510 * The operation was not allowed by the current state of the object. | 508 * The operation was not allowed by the current state of the object. |
511 * | 509 * |
512 * This is a generic error used for a variety of different erroneous | 510 * This is a generic error used for a variety of different erroneous |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
564 * the first time it is read. If evaluating the initializer expression causes | 562 * the first time it is read. If evaluating the initializer expression causes |
565 * another read of the variable, this error is thrown. | 563 * another read of the variable, this error is thrown. |
566 */ | 564 */ |
567 class CyclicInitializationError extends Error { | 565 class CyclicInitializationError extends Error { |
568 final String variableName; | 566 final String variableName; |
569 CyclicInitializationError([this.variableName]); | 567 CyclicInitializationError([this.variableName]); |
570 String toString() => variableName == null | 568 String toString() => variableName == null |
571 ? "Reading static variable during its initialization" | 569 ? "Reading static variable during its initialization" |
572 : "Reading static variable '$variableName' during its initialization"; | 570 : "Reading static variable '$variableName' during its initialization"; |
573 } | 571 } |
OLD | NEW |