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 abstract class Exception { |
12 // TODO(lrn): This should be an abstract class, but we don't yet support | 12 const factory Exception([var message]) = _ExceptionImplementation; |
13 // redirecting factory constructors. | |
14 const Exception([var message]); | |
15 } | 13 } |
16 | 14 |
17 | 15 |
18 /** Default implementation of [Exception] which carries a message. */ | 16 /** Default implementation of [Exception] which carries a message. */ |
19 class _ExceptionImplementation implements Exception { | 17 class _ExceptionImplementation implements Exception { |
20 final message; | 18 final message; |
21 const _ExceptionImplementation([this.message]); | 19 const _ExceptionImplementation([this.message]); |
22 String toString() => (message == null) ? "Exception" : "Exception: $message"; | 20 String toString() => (message == null) ? "Exception" : "Exception: $message"; |
23 } | 21 } |
24 | 22 |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 } | 73 } |
76 | 74 |
77 /** | 75 /** |
78 * Exception thrown when a runtime error occurs. | 76 * Exception thrown when a runtime error occurs. |
79 */ | 77 */ |
80 class RuntimeError implements Exception { | 78 class RuntimeError implements Exception { |
81 final message; | 79 final message; |
82 RuntimeError(this.message); | 80 RuntimeError(this.message); |
83 String toString() => "RuntimeError: $message"; | 81 String toString() => "RuntimeError: $message"; |
84 } | 82 } |
OLD | NEW |