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 */ | 9 */ |
10 interface Exception default ExceptionImplementation { | 10 interface Exception default ExceptionImplementation { |
(...skipping 20 matching lines...) Expand all Loading... | |
31 } | 31 } |
32 | 32 |
33 | 33 |
34 /** | 34 /** |
35 * Exception thrown because of non-existing receiver's method. | 35 * Exception thrown because of non-existing receiver's method. |
36 */ | 36 */ |
37 class NoSuchMethodException implements Exception { | 37 class NoSuchMethodException implements Exception { |
38 const NoSuchMethodException(Object this._receiver, | 38 const NoSuchMethodException(Object this._receiver, |
39 String this._functionName, | 39 String this._functionName, |
40 List this._arguments, | 40 List this._arguments, |
41 [List existingArgumentNames = null]) : | 41 [List existingArgumentNames = null]) : |
42 this._existingArgumentNames = existingArgumentNa mes; | 42 this._existingArgumentNames = existingArgumentNa mes; |
floitsch
2012/06/25 18:21:09
not your code, but 80chars.
Lasse Reichstein Nielsen
2012/06/26 08:26:03
Done.
| |
43 | 43 |
44 String toString() { | 44 String toString() { |
45 StringBuffer sb = new StringBuffer(); | 45 StringBuffer sb = new StringBuffer(); |
46 for (int i = 0; i < _arguments.length; i++) { | 46 for (int i = 0; i < _arguments.length; i++) { |
47 if (i > 0) { | 47 if (i > 0) { |
48 sb.add(", "); | 48 sb.add(", "); |
49 } | 49 } |
50 sb.add(_arguments[i]); | 50 sb.add(_arguments[i]); |
51 } | 51 } |
52 if (_existingArgumentNames === null) { | 52 if (_existingArgumentNames === null) { |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
133 } | 133 } |
134 } | 134 } |
135 | 135 |
136 String get exceptionName() => "NullPointerException"; | 136 String get exceptionName() => "NullPointerException"; |
137 | 137 |
138 final String functionName; | 138 final String functionName; |
139 final List arguments; | 139 final List arguments; |
140 } | 140 } |
141 | 141 |
142 | 142 |
143 class CastException implements Exception { | |
144 // TODO(lrn): Change actualType and expectedType to "Type" when reified | |
145 // types are available. | |
146 final Object actualType; | |
147 final Object expectedType; | |
148 | |
149 CastException(this.actualType, this.expectedType); | |
150 String toString() { | |
151 return "$exceptionName: Casting value of type $actualType to" | |
152 " incompatible type $expectedType"; | |
153 } | |
154 | |
155 String get exceptionName() => "CastException"; | |
156 } | |
157 | |
158 | |
143 class NoMoreElementsException implements Exception { | 159 class NoMoreElementsException implements Exception { |
144 const NoMoreElementsException(); | 160 const NoMoreElementsException(); |
145 String toString() => "NoMoreElementsException"; | 161 String toString() => "NoMoreElementsException"; |
146 } | 162 } |
147 | 163 |
148 | 164 |
149 class EmptyQueueException implements Exception { | 165 class EmptyQueueException implements Exception { |
150 const EmptyQueueException(); | 166 const EmptyQueueException(); |
151 String toString() => "EmptyQueueException"; | 167 String toString() => "EmptyQueueException"; |
152 } | 168 } |
(...skipping 20 matching lines...) Expand all Loading... | |
173 String toString() => "IllegalJSRegExpException: '$_pattern' '$_errmsg'"; | 189 String toString() => "IllegalJSRegExpException: '$_pattern' '$_errmsg'"; |
174 final String _pattern; | 190 final String _pattern; |
175 final String _errmsg; | 191 final String _errmsg; |
176 } | 192 } |
177 | 193 |
178 | 194 |
179 class IntegerDivisionByZeroException implements Exception { | 195 class IntegerDivisionByZeroException implements Exception { |
180 const IntegerDivisionByZeroException(); | 196 const IntegerDivisionByZeroException(); |
181 String toString() => "IntegerDivisionByZeroException"; | 197 String toString() => "IntegerDivisionByZeroException"; |
182 } | 198 } |
OLD | NEW |