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 24 matching lines...) Expand all Loading... |
35 | 35 |
36 String toString() { | 36 String toString() { |
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. |
| 46 * |
| 47 * Temporarily extends [Exception] for backwards compatiblity. |
| 48 */ |
| 49 class RangeError extends ArgumentError implements Exception { |
| 50 // TODO(lrn): This constructor should be called only with string values. |
| 51 // It currently isn't in all cases. |
| 52 /** Create a new [RangeError] with the given [message]. */ |
| 53 RangeError(var message) : super("$message"); |
| 54 |
| 55 /** Create a new [RangeError] with a message for the given [value]. */ |
| 56 RangeError.value(num value) : super("value $value"); |
| 57 |
| 58 String toString() => "RangeError: $message"; |
| 59 } |
| 60 |
| 61 /** |
| 62 * Temporary backwards compatibilty class. |
| 63 * |
| 64 * This class allows code throwing the old [IndexOutOfRangeException] to |
| 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 */ |
| 69 class IndexOutOfRangeException extends ArgumentError { |
| 70 IndexOutOfRangeException(var message) : super(message); |
| 71 } |
| 72 |
| 73 |
| 74 /** |
45 * Temporary backwards compatibility class. | 75 * Temporary backwards compatibility class. |
46 * | 76 * |
47 * Removed when users have had time to change to using [ArgumentError]. | 77 * Removed when users have had time to change to using [ArgumentError]. |
48 */ | 78 */ |
49 class IllegalArgumentException extends ArgumentError { | 79 class IllegalArgumentException extends ArgumentError { |
50 const IllegalArgumentException([argument = ""]) : super(argument); | 80 const IllegalArgumentException([argument = ""]) : super(argument); |
51 } | 81 } |
52 | 82 |
53 /** | 83 /** |
54 * Error thrown when control reaches the end of a switch case. | 84 * Error thrown when control reaches the end of a switch case. |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 | 221 |
192 class OutOfMemoryError implements Error { | 222 class OutOfMemoryError implements Error { |
193 const OutOfMemoryError(); | 223 const OutOfMemoryError(); |
194 String toString() => "Out of Memory"; | 224 String toString() => "Out of Memory"; |
195 } | 225 } |
196 | 226 |
197 class StackOverflowError implements Error { | 227 class StackOverflowError implements Error { |
198 const StackOverflowError(); | 228 const StackOverflowError(); |
199 String toString() => "Stack Overflow"; | 229 String toString() => "Stack Overflow"; |
200 } | 230 } |
OLD | NEW |