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 // TODO(lrn): Rename to CastError according to specification. | 15 // TODO(lrn): Rename to CastError according to specification. |
16 class CastException implements Error { | 16 class CastException implements Error { |
17 } | 17 } |
18 | 18 |
19 /** | |
20 * Error thrown when a function is passed an unacceptable argument. | |
21 */ | |
22 class ArgumentError implements Error { | |
23 final message; | |
24 | |
25 /** The [message] describes the erroneous argument. */ | |
26 const ArgumentError([this.message = ""]); | |
27 | |
28 String toString() => "Illegal argument(s): $message"; | |
Søren Gjesse
2012/09/25 12:22:24
Shouldn't the toString result be without the ": "
Lasse Reichstein Nielsen
2012/09/25 12:28:07
It should, yes.
| |
29 } | |
30 | |
31 /** | |
32 * Temporary backwards compatibility class. | |
33 * | |
34 * Removed when users have had time to change to using [ArgumentError]. | |
35 */ | |
36 class IllegalArgumentException extends ArgumentError { | |
37 const IllegalArgumentException([argument = ""]) : super(argument); | |
38 } | |
39 | |
40 | |
19 class FallThroughError implements Error { | 41 class FallThroughError implements Error { |
20 const FallThroughError(); | 42 const FallThroughError(); |
21 } | 43 } |
22 | 44 |
23 class AbstractClassInstantiationError { | 45 class AbstractClassInstantiationError { |
24 } | 46 } |
25 | 47 |
26 /** | 48 /** |
27 * Error thrown by the default implementation of [:noSuchMethod:] on [Object]. | 49 * Error thrown by the default implementation of [:noSuchMethod:] on [Object]. |
28 */ | 50 */ |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
93 .replaceAll('\n', '${backslash}n') | 115 .replaceAll('\n', '${backslash}n') |
94 .replaceAll('\r', '${backslash}r') | 116 .replaceAll('\r', '${backslash}r') |
95 .replaceAll('"', '$backslash"'); | 117 .replaceAll('"', '$backslash"'); |
96 return '"$escaped"'; | 118 return '"$escaped"'; |
97 } | 119 } |
98 return _objectToString(object); | 120 return _objectToString(object); |
99 } | 121 } |
100 | 122 |
101 external static _objectToString(Object object); | 123 external static _objectToString(Object object); |
102 } | 124 } |
OLD | NEW |