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 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 * | 202 * |
203 * This [Error] is thrown when a class cannot implement | 203 * This [Error] is thrown when a class cannot implement |
204 * one of the methods in its signature. | 204 * one of the methods in its signature. |
205 */ | 205 */ |
206 class UnsupportedError implements Error { | 206 class UnsupportedError implements Error { |
207 final String message; | 207 final String message; |
208 UnsupportedError(this.message); | 208 UnsupportedError(this.message); |
209 String toString() => "Unsupported operation: $message"; | 209 String toString() => "Unsupported operation: $message"; |
210 } | 210 } |
211 | 211 |
| 212 |
| 213 /** |
| 214 * Thrown by operations that have not been implemented yet. |
| 215 * |
| 216 * This [Error] is thrown by unfinished code that hasn't yet implemented |
| 217 * all the features it needs. |
| 218 * |
| 219 * If a class is not intending to implement the feature, it should throw |
| 220 * an [UnsupportedError] instead. This error is only intended for |
| 221 * use during development. |
| 222 * |
| 223 * This class temporarily implements [Exception] for backwards compatibility. |
| 224 * The constructor is temporarily const to support [NotImplementedException]. |
| 225 */ |
| 226 class UnimplementedError implements UnsupportedError, NotImplementedException { |
| 227 final String message; |
| 228 const UnimplementedError([String this.message]); |
| 229 String toString() => (this.message !== null |
| 230 ? "UnimplementedError: $message" |
| 231 : "UnimplementedError"); |
| 232 } |
| 233 |
| 234 |
| 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 |
212 /** | 241 /** |
213 * The operation was not allowed by the current state of the object. | 242 * The operation was not allowed by the current state of the object. |
214 * | 243 * |
215 * This is a generic error used for a variety of different erroneous | 244 * This is a generic error used for a variety of different erroneous |
216 * actions. The message should be descriptive. | 245 * actions. The message should be descriptive. |
217 */ | 246 */ |
218 class StateError implements Error { | 247 class StateError implements Error { |
219 final String message; | 248 final String message; |
220 StateError(this.message); | 249 StateError(this.message); |
221 String toString() => "Bad state: $message"; | 250 String toString() => "Bad state: $message"; |
222 } | 251 } |
223 | 252 |
224 | 253 |
225 class OutOfMemoryError implements Error { | 254 class OutOfMemoryError implements Error { |
226 const OutOfMemoryError(); | 255 const OutOfMemoryError(); |
227 String toString() => "Out of Memory"; | 256 String toString() => "Out of Memory"; |
228 } | 257 } |
229 | 258 |
230 class StackOverflowError implements Error { | 259 class StackOverflowError implements Error { |
231 const StackOverflowError(); | 260 const StackOverflowError(); |
232 String toString() => "Stack Overflow"; | 261 String toString() => "Stack Overflow"; |
233 } | 262 } |
OLD | NEW |