| 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 // Exceptions are thrown either by the VM or from Dart code. | 5 // Exceptions are thrown either by the VM or from Dart code. |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * Interface implemented by all core library exceptions. | 8 * Interface implemented by all core library exceptions. |
| 9 * Defaults to an implementation that only carries a simple message. | 9 * Defaults to an implementation that only carries a simple message. |
| 10 */ | 10 */ |
| 11 interface Exception default ExceptionImplementation { | 11 interface Exception default _ExceptionImplementation { |
| 12 // TODO(lrn): This should be an abstract class, but we don't yet support |
| 13 // redirecting factory constructors. |
| 12 const Exception([var message]); | 14 const Exception([var message]); |
| 13 } | 15 } |
| 14 | 16 |
| 15 | 17 |
| 18 /** Default implementation of [Exception] which carries a message. */ |
| 19 class _ExceptionImplementation implements Exception { |
| 20 final message; |
| 21 const _ExceptionImplementation([this.message]); |
| 22 String toString() => (message == null) ? "Exception" : "Exception: $message"; |
| 23 } |
| 24 |
| 25 |
| 16 /** | 26 /** |
| 17 * Exception thrown because of an index outside of the valid range. | 27 * Exception thrown because of an index outside of the valid range. |
| 18 */ | 28 */ |
| 19 class IndexOutOfRangeException implements Exception { | 29 class IndexOutOfRangeException implements Exception { |
| 20 const IndexOutOfRangeException(this._value); | 30 const IndexOutOfRangeException(this._value); |
| 21 | 31 |
| 22 String toString() => "IndexOutOfRangeException: $_value"; | 32 String toString() => "IndexOutOfRangeException: $_value"; |
| 23 | 33 |
| 24 final _value; | 34 final _value; |
| 25 } | 35 } |
| 26 | 36 |
| 27 | |
| 28 /** | 37 /** |
| 29 * Exception thrown because of attempt to modify an immutable object. | 38 * Exception thrown because of attempt to modify an immutable object. |
| 30 */ | 39 */ |
| 31 class IllegalAccessException implements Exception { | 40 class IllegalAccessException implements Exception { |
| 32 const IllegalAccessException(); | 41 const IllegalAccessException(); |
| 33 String toString() => "Attempt to modify an immutable object"; | 42 String toString() => "Attempt to modify an immutable object"; |
| 34 } | 43 } |
| 35 | 44 |
| 36 | 45 |
| 37 class ClosureArgumentMismatchException implements Exception { | 46 class ClosureArgumentMismatchException implements Exception { |
| 38 const ClosureArgumentMismatchException(); | 47 const ClosureArgumentMismatchException(); |
| 39 String toString() => "Closure argument mismatch"; | 48 String toString() => "Closure argument mismatch"; |
| 40 } | 49 } |
| 41 | 50 |
| 42 | 51 |
| 43 class ObjectNotClosureException implements Exception { | 52 class ObjectNotClosureException implements Exception { |
| 44 const ObjectNotClosureException(); | 53 const ObjectNotClosureException(); |
| 45 String toString() => "Object is not closure"; | 54 String toString() => "Object is not closure"; |
| 46 } | 55 } |
| 47 | 56 |
| 48 | 57 |
| 49 class OutOfMemoryException implements Exception { | |
| 50 const OutOfMemoryException(); | |
| 51 String toString() => "Out of Memory"; | |
| 52 } | |
| 53 | |
| 54 | |
| 55 class StackOverflowException implements Exception { | 58 class StackOverflowException implements Exception { |
| 56 const StackOverflowException(); | 59 const StackOverflowException(); |
| 57 String toString() => "Stack Overflow"; | 60 String toString() => "Stack Overflow"; |
| 58 } | 61 } |
| 59 | 62 |
| 60 | 63 |
| 61 /** | 64 /** |
| 62 * Exception thrown when a string or some other data does not have an expected | 65 * Exception thrown when a string or some other data does not have an expected |
| 63 * format and cannot be parsed or processed. | 66 * format and cannot be parsed or processed. |
| 64 */ | 67 */ |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 } | 147 } |
| 145 | 148 |
| 146 /** | 149 /** |
| 147 * Exception thrown when a runtime error occurs. | 150 * Exception thrown when a runtime error occurs. |
| 148 */ | 151 */ |
| 149 class RuntimeError implements Exception { | 152 class RuntimeError implements Exception { |
| 150 final message; | 153 final message; |
| 151 RuntimeError(this.message); | 154 RuntimeError(this.message); |
| 152 String toString() => "RuntimeError: $message"; | 155 String toString() => "RuntimeError: $message"; |
| 153 } | 156 } |
| OLD | NEW |