| 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 class AssertionError implements Error { | 9 class AssertionError implements Error { |
| 10 } | 10 } |
| 11 | 11 |
| 12 class TypeError implements AssertionError { | 12 class TypeError implements AssertionError { |
| 13 } | 13 } |
| 14 | 14 |
| 15 class CastError implements Error { | 15 class CastError implements Error { |
| 16 } | 16 } |
| 17 | 17 |
| 18 /** | 18 /** |
| 19 * Error thrown when a function is passed an unacceptable argument. | 19 * Error thrown when a function is passed an unacceptable argument. |
| 20 */ | 20 */class ArgumentError implements Error { |
| 21 class ArgumentError implements Error { | |
| 22 final message; | 21 final message; |
| 23 | 22 |
| 24 /** The [message] describes the erroneous argument. */ | 23 /** The [message] describes the erroneous argument. */ |
| 25 const ArgumentError([this.message = ""]); | 24 const ArgumentError([this.message = ""]); |
| 26 | 25 |
| 27 String toString() { | 26 String toString() { |
| 28 if (message != null) { | 27 if (message != null) { |
| 29 return "Illegal argument(s): $message"; | 28 return "Illegal argument(s): $message"; |
| 30 } | 29 } |
| 31 return "Illegal argument(s)"; | 30 return "Illegal argument(s)"; |
| 32 } | 31 } |
| 33 } | 32 } |
| 34 | 33 |
| 35 /** | 34 /** |
| 36 * Temporary backwards compatibility class. | 35 * Temporary backwards compatibility class. |
| 37 * | 36 * |
| 38 * Removed when users have had time to change to using [ArgumentError]. | 37 * Removed when users have had time to change to using [ArgumentError]. |
| 39 */ | 38 */ |
| 40 class IllegalArgumentException extends ArgumentError { | 39 class IllegalArgumentException extends ArgumentError { |
| 41 const IllegalArgumentException([argument = ""]) : super(argument); | 40 const IllegalArgumentException([argument = ""]) : super(argument); |
| 42 } | 41 } |
| 43 | 42 |
| 44 | 43 /** |
| 44 * Error thrown when control reaches the end of a switch case. |
| 45 * |
| 46 * The Dart specification requires this error to be thrown when |
| 47 * control reaches the end of a switch case (except the last case |
| 48 * of a switch) without meeting a break or similar end of the control |
| 49 * flow. |
| 50 */ |
| 45 class FallThroughError implements Error { | 51 class FallThroughError implements Error { |
| 46 const FallThroughError(); | 52 const FallThroughError(); |
| 47 } | 53 } |
| 48 | 54 |
| 49 class AbstractClassInstantiationError implements Error { | 55 class AbstractClassInstantiationError implements Error { |
| 50 final String _className; | 56 final String _className; |
| 51 const AbstractClassInstantiationError(String this._className); | 57 const AbstractClassInstantiationError(String this._className); |
| 52 String toString() => "Cannot instantiate abstract class: '$_className'"; | 58 String toString() => "Cannot instantiate abstract class: '$_className'"; |
| 53 } | 59 } |
| 54 | 60 |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 .replaceAll('"', '$backslash"'); | 130 .replaceAll('"', '$backslash"'); |
| 125 return '"$escaped"'; | 131 return '"$escaped"'; |
| 126 } | 132 } |
| 127 return _objectToString(object); | 133 return _objectToString(object); |
| 128 } | 134 } |
| 129 | 135 |
| 130 external static String _objectToString(Object object); | 136 external static String _objectToString(Object object); |
| 131 } | 137 } |
| 132 | 138 |
| 133 | 139 |
| 134 class OutOfMemoryError implements Exception { | 140 class OutOfMemoryError implements Error { |
| 135 const OutOfMemoryError(); | 141 const OutOfMemoryError(); |
| 136 String toString() => "Out of Memory"; | 142 String toString() => "Out of Memory"; |
| 137 } | 143 } |
| 144 |
| 145 class StackOverflowError implements Error { |
| 146 const StackOverflowError(); |
| 147 String toString() => "Stack Overflow"; |
| 148 } |
| OLD | NEW |