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

Side by Side Diff: sdk/lib/core/errors.dart

Issue 12297010: - Split the implementation of NoSuchMethodError in preparation for (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 10 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
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/lib/core_patch.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 part of dart.core; 5 part of dart.core;
6 6
7 class Error { 7 class Error {
8 const Error(); 8 const Error();
9 9
10 /** 10 /**
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 * method with the same name on the receiver, if available. This is 144 * method with the same name on the receiver, if available. This is
145 * the method that would have been called if the parameters had matched. 145 * the method that would have been called if the parameters had matched.
146 */ 146 */
147 const NoSuchMethodError(Object this._receiver, 147 const NoSuchMethodError(Object this._receiver,
148 String this._memberName, 148 String this._memberName,
149 List this._arguments, 149 List this._arguments,
150 Map<String,dynamic> this._namedArguments, 150 Map<String,dynamic> this._namedArguments,
151 [List existingArgumentNames = null]) 151 [List existingArgumentNames = null])
152 : this._existingArgumentNames = existingArgumentNames; 152 : this._existingArgumentNames = existingArgumentNames;
153 153
154 String toString() { 154 external String toString();
155 StringBuffer sb = new StringBuffer();
156 int i = 0;
157 if (_arguments != null) {
158 for (; i < _arguments.length; i++) {
159 if (i > 0) {
160 sb.add(", ");
161 }
162 sb.add(Error.safeToString(_arguments[i]));
163 }
164 }
165 if (_namedArguments != null) {
166 _namedArguments.forEach((String key, var value) {
167 if (i > 0) {
168 sb.add(", ");
169 }
170 sb.add(key);
171 sb.add(": ");
172 sb.add(Error.safeToString(value));
173 i++;
174 });
175 }
176 if (_existingArgumentNames == null) {
177 return "NoSuchMethodError : method not found: '$_memberName'\n"
178 "Receiver: ${Error.safeToString(_receiver)}\n"
179 "Arguments: [$sb]";
180 } else {
181 String actualParameters = sb.toString();
182 sb = new StringBuffer();
183 for (int i = 0; i < _existingArgumentNames.length; i++) {
184 if (i > 0) {
185 sb.add(", ");
186 }
187 sb.add(_existingArgumentNames[i]);
188 }
189 String formalParameters = sb.toString();
190 return "NoSuchMethodError: incorrect number of arguments passed to "
191 "method named '$_memberName'\n"
192 "Receiver: ${Error.safeToString(_receiver)}\n"
193 "Tried calling: $_memberName($actualParameters)\n"
194 "Found: $_memberName($formalParameters)";
195 }
196 }
197 } 155 }
198 156
199 157
200 /** 158 /**
201 * The operation was not allowed by the object. 159 * The operation was not allowed by the object.
202 * 160 *
203 * This [Error] is thrown when an instance cannot implement one of the methods 161 * This [Error] is thrown when an instance cannot implement one of the methods
204 * in its signature. 162 * in its signature.
205 */ 163 */
206 class UnsupportedError implements Error { 164 class UnsupportedError implements Error {
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 } 234 }
277 235
278 /** 236 /**
279 * Error thrown when a runtime error occurs. 237 * Error thrown when a runtime error occurs.
280 */ 238 */
281 class RuntimeError implements Error { 239 class RuntimeError implements Error {
282 final message; 240 final message;
283 RuntimeError(this.message); 241 RuntimeError(this.message);
284 String toString() => "RuntimeError: $message"; 242 String toString() => "RuntimeError: $message";
285 } 243 }
OLDNEW
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/lib/core_patch.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698