Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(94)

Side by Side Diff: corelib/src/exceptions.dart

Issue 10540048: Implement 'as' operator. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Update semantics to not throw on null. Merge to head. Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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;
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 }
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 {
ahe 2012/06/25 10:36:56 We generally put fields before constructors which
Lasse Reichstein Nielsen 2012/06/25 11:20:06 I know. I was following the convention of the file
Lasse Reichstein Nielsen 2012/06/25 15:16:07 Ah, to heck with consistency. I'll move them up he
144 // TODO(lrn): Change expectedType to "Type" when reified types are in.
ahe 2012/06/25 10:36:56 This comment applies to the field below.
Lasse Reichstein Nielsen 2012/06/25 11:20:06 True. I put the comment at the first instance of t
145 CastException(this.actualValue, this.expectedType);
146 String toString() {
147 if (expectedType !== null) {
148 return "$exceptionName : Casting $actualValue to $expectedType";
ahe 2012/06/25 10:36:56 You don't put a space after the exception. The abo
Lasse Reichstein Nielsen 2012/06/25 11:20:06 The actualValue is the value being cast, yes. As d
Lasse Reichstein Nielsen 2012/06/25 15:16:07 I also removed the special casing for when the typ
149 } else {
150 return "$exceptionName : Bad cast of $actualValue";
151 }
152 }
153
154 String get exceptionName() => "CastException";
ahe 2012/06/25 10:36:56 What is this for? Localization doesn't work well w
Lasse Reichstein Nielsen 2012/06/25 11:20:06 Again I'm following the surrounding code. I assume
ahe 2012/06/25 11:57:03 That the surrounding code is broken is no excuse f
Lasse Reichstein Nielsen 2012/06/25 12:51:10 I don't think the style guide makes any recommenda
155
156 final Object actualValue;
157 final Object expectedType;
158 }
159
160
143 class NoMoreElementsException implements Exception { 161 class NoMoreElementsException implements Exception {
144 const NoMoreElementsException(); 162 const NoMoreElementsException();
145 String toString() => "NoMoreElementsException"; 163 String toString() => "NoMoreElementsException";
146 } 164 }
147 165
148 166
149 class EmptyQueueException implements Exception { 167 class EmptyQueueException implements Exception {
150 const EmptyQueueException(); 168 const EmptyQueueException();
151 String toString() => "EmptyQueueException"; 169 String toString() => "EmptyQueueException";
152 } 170 }
(...skipping 20 matching lines...) Expand all
173 String toString() => "IllegalJSRegExpException: '$_pattern' '$_errmsg'"; 191 String toString() => "IllegalJSRegExpException: '$_pattern' '$_errmsg'";
174 final String _pattern; 192 final String _pattern;
175 final String _errmsg; 193 final String _errmsg;
176 } 194 }
177 195
178 196
179 class IntegerDivisionByZeroException implements Exception { 197 class IntegerDivisionByZeroException implements Exception {
180 const IntegerDivisionByZeroException(); 198 const IntegerDivisionByZeroException();
181 String toString() => "IntegerDivisionByZeroException"; 199 String toString() => "IntegerDivisionByZeroException";
182 } 200 }
OLDNEW
« no previous file with comments | « no previous file | lib/compiler/implementation/lib/js_helper.dart » ('j') | lib/compiler/implementation/lib/js_helper.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698