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

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

Issue 10909166: Rename NoSuchMethodException to NoSuchMethodError. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address review comments Created 8 years, 3 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 | « lib/compiler/implementation/lib/native_helper.dart ('k') | lib/core/exceptions.dart » ('j') | 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 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 class FallThroughError implements Error { 19 class FallThroughError implements Error {
20 const FallThroughError(); 20 const FallThroughError();
21 } 21 }
22 22
23 class AbstractClassInstantiationError { 23 class AbstractClassInstantiationError {
24 } 24 }
25
26 /**
27 * Error thrown by the default implementation of [:noSuchMethod:] on [Object].
28 */
29 class NoSuchMethodError implements Error {
30 final Object _receiver;
31 final String _functionName;
32 final List _arguments;
33 final List _existingArgumentNames;
34
35 /**
36 * Create a [NoSuchMethodError] corresponding to a failed method call.
37 *
38 * The first parameter is the receiver of the method call.
39 * The second parameter is the name of the called method.
40 * The third parameter is the positional arguments that the method was
41 * called with.
42 * The optional [exisitingArgumentNames] is the expected parameters of a
43 * method with the same name on the receiver, if available. This is
44 * the method that would have been called if the parameters had matched.
45 *
46 * TODO(lrn): This will be rewritten to use mirrors when they are available.
47 */
48 const NoSuchMethodError(Object this._receiver,
49 String this._functionName,
50 List this._arguments,
51 [List existingArgumentNames = null])
52 : this._existingArgumentNames = existingArgumentNames;
53
54 String toString() {
55 StringBuffer sb = new StringBuffer();
56 for (int i = 0; i < _arguments.length; i++) {
57 if (i > 0) {
58 sb.add(", ");
59 }
60 sb.add(_arguments[i]);
61 }
62 if (_existingArgumentNames === null) {
63 return "NoSuchMethodError : method not found: '$_functionName'\n"
64 "Receiver: $_receiver\n"
65 "Arguments: [$sb]";
66 } else {
67 String actualParameters = sb.toString();
68 sb = new StringBuffer();
69 for (int i = 0; i < _existingArgumentNames.length; i++) {
70 if (i > 0) {
71 sb.add(", ");
72 }
73 sb.add(_existingArgumentNames[i]);
74 }
75 String formalParameters = sb.toString();
76 return "NoSuchMethodError: incorrect number of arguments passed to "
77 "method named '$_functionName'\nReceiver: $_receiver\n"
78 "Tried calling: $_functionName($actualParameters)\n"
79 "Found: $_functionName($formalParameters)";
80 }
81 }
82 }
OLDNEW
« no previous file with comments | « lib/compiler/implementation/lib/native_helper.dart ('k') | lib/core/exceptions.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698