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

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: 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
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 const NoSuchMethodError(Object this._receiver,
Johnni Winther 2012/09/11 08:41:38 Please add dartdoc to explain usage. In particular
Lasse Reichstein Nielsen 2012/09/11 11:35:41 Done.
36 String this._functionName,
37 List this._arguments,
38 [List existingArgumentNames = null])
39 : this._existingArgumentNames = existingArgumentNames;
40
41 String toString() {
42 StringBuffer sb = new StringBuffer();
43 for (int i = 0; i < _arguments.length; i++) {
44 if (i > 0) {
45 sb.add(", ");
46 }
47 sb.add(_arguments[i]);
48 }
49 if (_existingArgumentNames === null) {
50 return "NoSuchMethodError : method not found: '$_functionName'\n"
51 "Receiver: $_receiver\n"
52 "Arguments: [$sb]";
53 } else {
54 String actualParameters = sb.toString();
55 sb = new StringBuffer();
56 for (int i = 0; i < _existingArgumentNames.length; i++) {
57 if (i > 0) {
58 sb.add(", ");
59 }
60 sb.add(_existingArgumentNames[i]);
61 }
62 String formalParameters = sb.toString();
63 return "NoSuchMethodError: incorrect number of arguments passed to "
64 "method named '$_functionName'\nReceiver: $_receiver\n"
65 "Tried calling: $_functionName($actualParameters)\n"
66 "Found: $_functionName($formalParameters)";
67 }
68 }
69 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698