| 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 /** |
| 10 * Error thrown by the runtime system when an assert statement fails. |
| 11 */ |
| 9 class AssertionError implements Error { | 12 class AssertionError implements Error { |
| 10 } | 13 } |
| 11 | 14 |
| 15 /** |
| 16 * Error thrown by the runtime system when a type assertion fails. |
| 17 */ |
| 12 class TypeError implements AssertionError { | 18 class TypeError implements AssertionError { |
| 13 } | 19 } |
| 14 | 20 |
| 21 /** |
| 22 * Error thrown by the runtime system when a cast operation fails. |
| 23 */ |
| 15 class CastError implements Error { | 24 class CastError implements Error { |
| 16 } | 25 } |
| 17 | 26 |
| 18 /** | 27 /** |
| 19 * Error thrown when a function is passed an unacceptable argument. | 28 * Error thrown when a function is passed an unacceptable argument. |
| 20 */class ArgumentError implements Error { | 29 */ |
| 30 class ArgumentError implements Error { |
| 21 final message; | 31 final message; |
| 22 | 32 |
| 23 /** The [message] describes the erroneous argument. */ | 33 /** The [message] describes the erroneous argument. */ |
| 24 const ArgumentError([this.message = ""]); | 34 const ArgumentError([this.message = ""]); |
| 25 | 35 |
| 26 String toString() { | 36 String toString() { |
| 27 if (message != null) { | 37 if (message != null) { |
| 28 return "Illegal argument(s): $message"; | 38 return "Illegal argument(s): $message"; |
| 29 } | 39 } |
| 30 return "Illegal argument(s)"; | 40 return "Illegal argument(s)"; |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 .replaceAll('"', '$backslash"'); | 140 .replaceAll('"', '$backslash"'); |
| 131 return '"$escaped"'; | 141 return '"$escaped"'; |
| 132 } | 142 } |
| 133 return _objectToString(object); | 143 return _objectToString(object); |
| 134 } | 144 } |
| 135 | 145 |
| 136 external static String _objectToString(Object object); | 146 external static String _objectToString(Object object); |
| 137 } | 147 } |
| 138 | 148 |
| 139 | 149 |
| 150 /** |
| 151 * The operation was not allowed by the object. |
| 152 * |
| 153 * This [Error] is thrown when a class cannot implement |
| 154 * one of the methods in its signature. |
| 155 */ |
| 156 class UnsupportedError implements Error { |
| 157 final String message; |
| 158 UnsupportedError(this.message); |
| 159 String toString() => message; |
| 160 } |
| 161 |
| 162 /** |
| 163 * The operation was not allowed by the current state of the object. |
| 164 * |
| 165 * This is a generic error used for a variety of different erroneous |
| 166 * actions. The message should be descriptive. |
| 167 */ |
| 168 class StateError implements Error { |
| 169 final String message; |
| 170 StateError(this.message); |
| 171 String toString() => message; |
| 172 } |
| 173 |
| 174 |
| 140 class OutOfMemoryError implements Error { | 175 class OutOfMemoryError implements Error { |
| 141 const OutOfMemoryError(); | 176 const OutOfMemoryError(); |
| 142 String toString() => "Out of Memory"; | 177 String toString() => "Out of Memory"; |
| 143 } | 178 } |
| 144 | 179 |
| 145 class StackOverflowError implements Error { | 180 class StackOverflowError implements Error { |
| 146 const StackOverflowError(); | 181 const StackOverflowError(); |
| 147 String toString() => "Stack Overflow"; | 182 String toString() => "Stack Overflow"; |
| 148 } | 183 } |
| OLD | NEW |