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 implements [IndexOutOfRangeException] for backwards compatiblity. | |
48 */ | 47 */ |
49 class RangeError extends ArgumentError implements IndexOutOfRangeException { | 48 class RangeError extends ArgumentError { |
50 // TODO(lrn): This constructor should be called only with string values. | 49 // TODO(lrn): This constructor should be called only with string values. |
51 // It currently isn't in all cases. | 50 // It currently isn't in all cases. |
52 /** | 51 /** |
53 * Create a new [RangeError] with the given [message]. | 52 * Create a new [RangeError] with the given [message]. |
54 * | 53 * |
55 * Temporarily made const for backwards compatibilty. | 54 * Temporarily made const for backwards compatibilty. |
56 */ | 55 */ |
57 const RangeError(var message) : super(message); | 56 RangeError(var message) : super(message); |
58 | 57 |
59 /** Create a new [RangeError] with a message for the given [value]. */ | 58 /** Create a new [RangeError] with a message for the given [value]. */ |
60 RangeError.value(num value) : super("value $value"); | 59 RangeError.value(num value) : super("value $value"); |
61 | 60 |
62 String toString() => "RangeError: $message"; | 61 String toString() => "RangeError: $message"; |
63 } | 62 } |
64 | 63 |
65 /** | |
66 * Temporary backwards compatibilty class. | |
67 * | |
68 * This class allows code throwing the old [IndexOutOfRangeException] to | |
69 * work until they change to the new [RangeError] name. | |
70 * Constructor of [RangeError] is const only to support this interface. | |
71 */ | |
72 interface IndexOutOfRangeException extends Exception default RangeError { | |
73 const IndexOutOfRangeException(var message); | |
74 } | |
75 | |
76 | 64 |
77 /** | 65 /** |
78 * Temporary backwards compatibility class. | |
79 * | |
80 * Removed when users have had time to change to using [ArgumentError]. | |
81 */ | |
82 class IllegalArgumentException extends ArgumentError { | |
83 const IllegalArgumentException([argument = ""]) : super(argument); | |
84 } | |
85 | |
86 /** | |
87 * Error thrown when control reaches the end of a switch case. | 66 * Error thrown when control reaches the end of a switch case. |
88 * | 67 * |
89 * The Dart specification requires this error to be thrown when | 68 * The Dart specification requires this error to be thrown when |
90 * control reaches the end of a switch case (except the last case | 69 * control reaches the end of a switch case (except the last case |
91 * of a switch) without meeting a break or similar end of the control | 70 * of a switch) without meeting a break or similar end of the control |
92 * flow. | 71 * flow. |
93 */ | 72 */ |
94 class FallThroughError implements Error { | 73 class FallThroughError implements Error { |
95 const FallThroughError(); | 74 const FallThroughError(); |
96 } | 75 } |
97 | 76 |
| 77 |
98 class AbstractClassInstantiationError implements Error { | 78 class AbstractClassInstantiationError implements Error { |
99 final String _className; | 79 final String _className; |
100 const AbstractClassInstantiationError(String this._className); | 80 const AbstractClassInstantiationError(String this._className); |
101 String toString() => "Cannot instantiate abstract class: '$_className'"; | 81 String toString() => "Cannot instantiate abstract class: '$_className'"; |
102 } | 82 } |
103 | 83 |
104 /** | 84 /** |
105 * Error thrown by the default implementation of [:noSuchMethod:] on [Object]. | 85 * Error thrown by the default implementation of [:noSuchMethod:] on [Object]. |
106 */ | 86 */ |
107 class NoSuchMethodError implements Error { | 87 class NoSuchMethodError implements Error { |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 | 192 |
213 /** | 193 /** |
214 * Thrown by operations that have not been implemented yet. | 194 * Thrown by operations that have not been implemented yet. |
215 * | 195 * |
216 * This [Error] is thrown by unfinished code that hasn't yet implemented | 196 * This [Error] is thrown by unfinished code that hasn't yet implemented |
217 * all the features it needs. | 197 * all the features it needs. |
218 * | 198 * |
219 * If a class is not intending to implement the feature, it should throw | 199 * If a class is not intending to implement the feature, it should throw |
220 * an [UnsupportedError] instead. This error is only intended for | 200 * an [UnsupportedError] instead. This error is only intended for |
221 * use during development. | 201 * use during development. |
222 * | |
223 * This class temporarily implements [Exception] for backwards compatibility. | |
224 * The constructor is temporarily const to support [NotImplementedException]. | |
225 */ | 202 */ |
226 class UnimplementedError implements UnsupportedError, NotImplementedException { | 203 class UnimplementedError implements UnsupportedError { |
227 final String message; | 204 final String message; |
228 const UnimplementedError([String this.message]); | 205 UnimplementedError([String this.message]); |
229 String toString() => (this.message != null | 206 String toString() => (this.message != null |
230 ? "UnimplementedError: $message" | 207 ? "UnimplementedError: $message" |
231 : "UnimplementedError"); | 208 : "UnimplementedError"); |
232 } | 209 } |
233 | 210 |
234 | 211 |
235 /** Temporary class added for backwards compatibility. Will be removed. */ | |
236 interface NotImplementedException extends Exception default UnimplementedError { | |
237 const NotImplementedException([String message]); | |
238 } | |
239 | |
240 | |
241 /** | 212 /** |
242 * The operation was not allowed by the current state of the object. | 213 * The operation was not allowed by the current state of the object. |
243 * | 214 * |
244 * This is a generic error used for a variety of different erroneous | 215 * This is a generic error used for a variety of different erroneous |
245 * actions. The message should be descriptive. | 216 * actions. The message should be descriptive. |
246 */ | 217 */ |
247 class StateError implements Error { | 218 class StateError implements Error { |
248 final String message; | 219 final String message; |
249 StateError(this.message); | 220 StateError(this.message); |
250 String toString() => "Bad state: $message"; | 221 String toString() => "Bad state: $message"; |
251 } | 222 } |
252 | 223 |
253 | 224 |
254 class OutOfMemoryError implements Error { | 225 class OutOfMemoryError implements Error { |
255 const OutOfMemoryError(); | 226 const OutOfMemoryError(); |
256 String toString() => "Out of Memory"; | 227 String toString() => "Out of Memory"; |
257 } | 228 } |
258 | 229 |
259 class StackOverflowError implements Error { | 230 class StackOverflowError implements Error { |
260 const StackOverflowError(); | 231 const StackOverflowError(); |
261 String toString() => "Stack Overflow"; | 232 String toString() => "Stack Overflow"; |
262 } | 233 } |
OLD | NEW |