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

Unified Diff: runtime/lib/errors_patch.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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | sdk/lib/_internal/compiler/implementation/lib/core_patch.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/lib/errors_patch.dart
===================================================================
--- runtime/lib/errors_patch.dart (revision 18612)
+++ runtime/lib/errors_patch.dart (working copy)
@@ -37,4 +37,59 @@
namedArguments,
existingArgumentNames);
}
+
+ const NoSuchMethodError(Object this._receiver,
+ String this._memberName,
+ List this._arguments,
+ Map<String,dynamic> this._namedArguments,
+ [List existingArgumentNames = null])
+ : this._existingArgumentNames = existingArgumentNames;
+
+ /* patch */ String toString() {
+ StringBuffer actual_buf = new StringBuffer();
+ int i = 0;
+ if (_arguments != null) {
+ for (; i < _arguments.length; i++) {
+ if (i > 0) {
+ actual_buf.add(", ");
+ }
+ actual_buf.add(Error.safeToString(_arguments[i]));
+ }
+ }
+ if (_namedArguments != null) {
+ _namedArguments.forEach((String key, var value) {
+ if (i > 0) {
+ actual_buf.add(", ");
+ }
+ actual_buf.add(key);
+ actual_buf.add(": ");
+ actual_buf.add(Error.safeToString(value));
+ i++;
+ });
+ }
+ StringBuffer msg_buf = new StringBuffer();
+ if (_existingArgumentNames == null) {
+ msg_buf.add(
+ "NoSuchMethodError : method not found: '$_memberName'\n"
+ "Receiver: ${Error.safeToString(_receiver)}\n"
+ "Arguments: [$actual_buf]");
+ } else {
+ String actualParameters = actual_buf.toString();
+ StringBuffer formal_buf = new StringBuffer();
+ for (int i = 0; i < _existingArgumentNames.length; i++) {
+ if (i > 0) {
+ formal_buf.add(", ");
+ }
+ formal_buf.add(_existingArgumentNames[i]);
+ }
+ String formalParameters = formal_buf.toString();
+ msg_buf.add(
+ "NoSuchMethodError: incorrect number of arguments passed to "
+ "method named '$_memberName'\n"
+ "Receiver: ${Error.safeToString(_receiver)}\n"
+ "Tried calling: $_memberName($actualParameters)\n"
+ "Found: $_memberName($formalParameters)");
+ }
+ return msg_buf.toString();
+ }
}
« no previous file with comments | « no previous file | sdk/lib/_internal/compiler/implementation/lib/core_patch.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698