Chromium Code Reviews| Index: runtime/lib/errors_patch.dart |
| =================================================================== |
| --- runtime/lib/errors_patch.dart (revision 18787) |
| +++ runtime/lib/errors_patch.dart (working copy) |
| @@ -14,6 +14,7 @@ |
| // unresolved method. |
| static void _throwNew(Object receiver, |
| String memberName, |
| + int invocation_type, |
| List arguments, |
| List argumentNames, |
| List existingArgumentNames) { |
| @@ -31,20 +32,67 @@ |
| var arg_value = arguments[numPositionalArguments + i]; |
| namedArguments[argumentNames[i]] = arg_value; |
| } |
| - throw new NoSuchMethodError(receiver, |
| + throw new NoSuchMethodError._withType(receiver, |
| memberName, |
| + invocation_type, |
| positionalArguments, |
| namedArguments, |
| existingArgumentNames); |
| } |
| + final int _invocation_type; |
| + |
| const NoSuchMethodError(Object this._receiver, |
| String this._memberName, |
| List this._arguments, |
| Map<String,dynamic> this._namedArguments, |
| [List existingArgumentNames = null]) |
| + : this._existingArgumentNames = existingArgumentNames, |
| + this._invocation_type = 0; |
|
regis
2013/02/21 00:48:18
What is 0?
Ivan Posva
2013/02/21 18:51:40
Changed to -1 to mark invalid/unknown invocation t
|
| + |
| + const NoSuchMethodError._withType(Object this._receiver, |
| + String this._memberName, |
|
regis
2013/02/21 00:48:18
indentation
Ivan Posva
2013/02/21 18:51:40
Done.
|
| + this._invocation_type, |
| + List this._arguments, |
| + Map<String,dynamic> this._namedArguments, |
| + [List existingArgumentNames = null]) |
| : this._existingArgumentNames = existingArgumentNames; |
| + |
| + String _developerMessage() { |
| + var type = _invocation_type & _InvocationMirror._TYPE_MASK; |
| + var level = (_invocation_type >> _InvocationMirror._CALL_SHIFT) & |
| + _InvocationMirror._CALL_MASK; |
| + var type_str = |
| + (const ["method", "getter", "setter", "getter or setter"])[type]; |
| + var msg; |
| + switch (level) { |
| + case _InvocationMirror._DYNAMIC: { |
| + if (_receiver == null) { |
| + msg = "The null object does not support $type_str '$_memberName'."; |
| + } else { |
| + msg = "No $type_str '$_memberName' declared in class " |
| + "'${_receiver.runtimeType}'."; |
| + } |
| + break; |
| + } |
| + case _InvocationMirror._STATIC: { |
| + msg = "No static $type_str '$_memberName' declared in class " |
| + "'$_receiver'."; |
| + break; |
| + } |
| + case _InvocationMirror._CONSTRUCTOR: { |
| + msg = "No constructor '$_memberName' declared in class '$_receiver'."; |
| + break; |
| + } |
| + case _InvocationMirror._TOP_LEVEL: { |
| + msg = "No top-level $type_str '$_memberName' declared."; |
| + break; |
| + } |
| + } |
| + return msg; |
| + } |
| + |
| /* patch */ String toString() { |
| StringBuffer actual_buf = new StringBuffer(); |
| int i = 0; |
| @@ -67,7 +115,8 @@ |
| i++; |
| }); |
| } |
| - StringBuffer msg_buf = new StringBuffer(); |
| + StringBuffer msg_buf = new StringBuffer(_developerMessage()); |
| + msg_buf.add("\n\n"); |
| if (_existingArgumentNames == null) { |
| msg_buf.add( |
| "NoSuchMethodError : method not found: '$_memberName'\n" |