Chromium Code Reviews| 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 class Error { | 5 class Error { |
| 6 const Error(); | 6 const Error(); |
| 7 } | 7 } |
| 8 | 8 |
| 9 /** | 9 /** |
| 10 * Error thrown by the runtime system when an assert statement fails. | 10 * Error thrown by the runtime system when an assert statement fails. |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 37 if (message != null) { | 37 if (message != null) { |
| 38 return "Illegal argument(s): $message"; | 38 return "Illegal argument(s): $message"; |
| 39 } | 39 } |
| 40 return "Illegal argument(s)"; | 40 return "Illegal argument(s)"; |
| 41 } | 41 } |
| 42 } | 42 } |
| 43 | 43 |
| 44 /** | 44 /** |
| 45 * Exception thrown because of an index outside of the valid range. | 45 * Exception thrown because of an index outside of the valid range. |
| 46 * | 46 * |
| 47 * Temporarily extends [Exception] for backwards compatiblity. | 47 * Temporarily implements [IndexOutOfRangeException] for backwards compatiblity. |
| 48 */ | 48 */ |
| 49 class RangeError extends ArgumentError implements Exception { | 49 class RangeError extends ArgumentError implements IndexOutOfRangeException { |
| 50 // TODO(lrn): This constructor should be called only with string values. | 50 // TODO(lrn): This constructor should be called only with string values. |
| 51 // It currently isn't in all cases. | 51 // It currently isn't in all cases. |
| 52 /** Create a new [RangeError] with the given [message]. */ | 52 /** Create a new [RangeError] with the given [message]. */ |
| 53 RangeError(var message) : super("$message"); | 53 RangeError(var message) : super("$message"); |
| 54 | 54 |
| 55 /** Create a new [RangeError] with a message for the given [value]. */ | 55 /** Create a new [RangeError] with a message for the given [value]. */ |
| 56 RangeError.value(num value) : super("value $value"); | 56 RangeError.value(num value) : super("value $value"); |
| 57 | 57 |
| 58 String toString() => "RangeError: $message"; | 58 String toString() => "RangeError: $message"; |
| 59 } | 59 } |
| 60 | 60 |
| 61 /** | 61 /** |
| 62 * Temporary backwards compatibilty class. | 62 * Temporary backwards compatibilty class. |
| 63 * | 63 * |
| 64 * This class allows code throwing the old [IndexOutOfRangeException] to | 64 * This class allows code throwing the old [IndexOutOfRangeException] to |
| 65 * work until they change to the new [RangeError] name. | 65 * work until they change to the new [RangeError] name. |
| 66 * Code **catching** IndexOutOfRangeException will fail to catch | |
| 67 * the [RangeError] objects that are now thrown. | |
| 68 */ | 66 */ |
| 69 class IndexOutOfRangeException extends ArgumentError { | 67 interface IndexOutOfRangeException implements Exception default RangeError { |
|
Søren Gjesse
2012/11/02 08:14:57
interface still works?
Lasse Reichstein Nielsen
2012/11/02 08:20:29
Yes. Redirecting factory constructors don't work y
| |
| 70 IndexOutOfRangeException(var message) : super(message); | 68 IndexOutOfRangeException(var message); |
| 71 } | 69 } |
| 72 | 70 |
| 73 | 71 |
| 74 /** | 72 /** |
| 75 * Temporary backwards compatibility class. | 73 * Temporary backwards compatibility class. |
| 76 * | 74 * |
| 77 * Removed when users have had time to change to using [ArgumentError]. | 75 * Removed when users have had time to change to using [ArgumentError]. |
| 78 */ | 76 */ |
| 79 class IllegalArgumentException extends ArgumentError { | 77 class IllegalArgumentException extends ArgumentError { |
| 80 const IllegalArgumentException([argument = ""]) : super(argument); | 78 const IllegalArgumentException([argument = ""]) : super(argument); |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 221 | 219 |
| 222 class OutOfMemoryError implements Error { | 220 class OutOfMemoryError implements Error { |
| 223 const OutOfMemoryError(); | 221 const OutOfMemoryError(); |
| 224 String toString() => "Out of Memory"; | 222 String toString() => "Out of Memory"; |
| 225 } | 223 } |
| 226 | 224 |
| 227 class StackOverflowError implements Error { | 225 class StackOverflowError implements Error { |
| 228 const StackOverflowError(); | 226 const StackOverflowError(); |
| 229 String toString() => "Stack Overflow"; | 227 String toString() => "Stack Overflow"; |
| 230 } | 228 } |
| OLD | NEW |