OLD | NEW |
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 patch class Error { | 5 patch class Error { |
6 /* patch */ static String _objectToString(Object object) { | 6 /* patch */ static String _objectToString(Object object) { |
7 return Object._toString(object); | 7 return Object._toString(object); |
8 } | 8 } |
9 } | 9 } |
10 | 10 |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 } | 100 } |
101 return "$msg\n\n"; | 101 return "$msg\n\n"; |
102 } | 102 } |
103 | 103 |
104 /* patch */ String toString() { | 104 /* patch */ String toString() { |
105 StringBuffer actual_buf = new StringBuffer(); | 105 StringBuffer actual_buf = new StringBuffer(); |
106 int i = 0; | 106 int i = 0; |
107 if (_arguments != null) { | 107 if (_arguments != null) { |
108 for (; i < _arguments.length; i++) { | 108 for (; i < _arguments.length; i++) { |
109 if (i > 0) { | 109 if (i > 0) { |
110 actual_buf.add(", "); | 110 actual_buf.write(", "); |
111 } | 111 } |
112 actual_buf.add(Error.safeToString(_arguments[i])); | 112 actual_buf.write(Error.safeToString(_arguments[i])); |
113 } | 113 } |
114 } | 114 } |
115 if (_namedArguments != null) { | 115 if (_namedArguments != null) { |
116 _namedArguments.forEach((String key, var value) { | 116 _namedArguments.forEach((String key, var value) { |
117 if (i > 0) { | 117 if (i > 0) { |
118 actual_buf.add(", "); | 118 actual_buf.write(", "); |
119 } | 119 } |
120 actual_buf.add(key); | 120 actual_buf.write(key); |
121 actual_buf.add(": "); | 121 actual_buf.write(": "); |
122 actual_buf.add(Error.safeToString(value)); | 122 actual_buf.write(Error.safeToString(value)); |
123 i++; | 123 i++; |
124 }); | 124 }); |
125 } | 125 } |
126 var args_mismatch = _existingArgumentNames != null; | 126 var args_mismatch = _existingArgumentNames != null; |
127 StringBuffer msg_buf = new StringBuffer(_developerMessage(args_mismatch)); | 127 StringBuffer msg_buf = new StringBuffer(_developerMessage(args_mismatch)); |
128 if (!args_mismatch) { | 128 if (!args_mismatch) { |
129 msg_buf.add( | 129 msg_buf.write( |
130 "NoSuchMethodError : method not found: '$_memberName'\n" | 130 "NoSuchMethodError : method not found: '$_memberName'\n" |
131 "Receiver: ${Error.safeToString(_receiver)}\n" | 131 "Receiver: ${Error.safeToString(_receiver)}\n" |
132 "Arguments: [$actual_buf]"); | 132 "Arguments: [$actual_buf]"); |
133 } else { | 133 } else { |
134 String actualParameters = actual_buf.toString(); | 134 String actualParameters = actual_buf.toString(); |
135 StringBuffer formal_buf = new StringBuffer(); | 135 StringBuffer formal_buf = new StringBuffer(); |
136 for (int i = 0; i < _existingArgumentNames.length; i++) { | 136 for (int i = 0; i < _existingArgumentNames.length; i++) { |
137 if (i > 0) { | 137 if (i > 0) { |
138 formal_buf.add(", "); | 138 formal_buf.write(", "); |
139 } | 139 } |
140 formal_buf.add(_existingArgumentNames[i]); | 140 formal_buf.write(_existingArgumentNames[i]); |
141 } | 141 } |
142 String formalParameters = formal_buf.toString(); | 142 String formalParameters = formal_buf.toString(); |
143 msg_buf.add( | 143 msg_buf.write( |
144 "NoSuchMethodError: incorrect number of arguments passed to " | 144 "NoSuchMethodError: incorrect number of arguments passed to " |
145 "method named '$_memberName'\n" | 145 "method named '$_memberName'\n" |
146 "Receiver: ${Error.safeToString(_receiver)}\n" | 146 "Receiver: ${Error.safeToString(_receiver)}\n" |
147 "Tried calling: $_memberName($actualParameters)\n" | 147 "Tried calling: $_memberName($actualParameters)\n" |
148 "Found: $_memberName($formalParameters)"); | 148 "Found: $_memberName($formalParameters)"); |
149 } | 149 } |
150 return msg_buf.toString(); | 150 return msg_buf.toString(); |
151 } | 151 } |
152 } | 152 } |
OLD | NEW |