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 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
385 super.value(invalidValue, name, | 385 super.value(invalidValue, name, |
386 (message != null) ? message : "Index out of range"); | 386 (message != null) ? message : "Index out of range"); |
387 | 387 |
388 // Getters inherited from RangeError. | 388 // Getters inherited from RangeError. |
389 int get start => 0; | 389 int get start => 0; |
390 int get end => length - 1; | 390 int get end => length - 1; |
391 | 391 |
392 String get _errorName => "RangeError"; | 392 String get _errorName => "RangeError"; |
393 String get _errorExplanation { | 393 String get _errorExplanation { |
394 assert(_hasValue); | 394 assert(_hasValue); |
395 String target = Error.safeToString(indexable); | |
396 var explanation = ": index should be less than $length"; | |
397 if (invalidValue < 0) { | 395 if (invalidValue < 0) { |
398 explanation = ": index must not be negative"; | 396 return ": index must not be negative"; |
399 } | 397 } |
400 return explanation; | 398 if (length == 0) { |
| 399 return ": no indices are valid"; |
| 400 } |
| 401 return ": index should be less than $length"; |
401 } | 402 } |
402 } | 403 } |
403 | 404 |
404 | 405 |
405 /** | 406 /** |
406 * Error thrown when control reaches the end of a switch case. | 407 * Error thrown when control reaches the end of a switch case. |
407 * | 408 * |
408 * The Dart specification requires this error to be thrown when | 409 * The Dart specification requires this error to be thrown when |
409 * control reaches the end of a switch case (except the last case | 410 * control reaches the end of a switch case (except the last case |
410 * of a switch) without meeting a break or similar end of the control | 411 * of a switch) without meeting a break or similar end of the control |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
562 * the first time it is read. If evaluating the initializer expression causes | 563 * the first time it is read. If evaluating the initializer expression causes |
563 * another read of the variable, this error is thrown. | 564 * another read of the variable, this error is thrown. |
564 */ | 565 */ |
565 class CyclicInitializationError extends Error { | 566 class CyclicInitializationError extends Error { |
566 final String variableName; | 567 final String variableName; |
567 CyclicInitializationError([this.variableName]); | 568 CyclicInitializationError([this.variableName]); |
568 String toString() => variableName == null | 569 String toString() => variableName == null |
569 ? "Reading static variable during its initialization" | 570 ? "Reading static variable during its initialization" |
570 : "Reading static variable '$variableName' during its initialization"; | 571 : "Reading static variable '$variableName' during its initialization"; |
571 } | 572 } |
OLD | NEW |