Chromium Code Reviews| 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 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 } |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 58 String toString() => "Cannot instantiate abstract class: '$_className'"; | 58 String toString() => "Cannot instantiate abstract class: '$_className'"; |
| 59 } | 59 } |
| 60 | 60 |
| 61 /** | 61 /** |
| 62 * Error thrown by the default implementation of [:noSuchMethod:] on [Object]. | 62 * Error thrown by the default implementation of [:noSuchMethod:] on [Object]. |
| 63 */ | 63 */ |
| 64 class NoSuchMethodError implements Error { | 64 class NoSuchMethodError implements Error { |
| 65 final Object _receiver; | 65 final Object _receiver; |
| 66 final String _functionName; | 66 final String _functionName; |
| 67 final List _arguments; | 67 final List _arguments; |
| 68 final Map<String,Dynamic> _namedArguments; | |
|
floitsch
2012/10/23 13:04:35
String, Dynamic (space)
regis
2012/10/25 02:27:56
dynamic is now lower case.
Lasse Reichstein Nielsen
2012/10/25 06:17:35
I actually have come to prefer it without spaces.
| |
| 68 final List _existingArgumentNames; | 69 final List _existingArgumentNames; |
| 69 | 70 |
| 70 /** | 71 /** |
| 71 * Create a [NoSuchMethodError] corresponding to a failed method call. | 72 * Create a [NoSuchMethodError] corresponding to a failed method call. |
| 72 * | 73 * |
| 73 * The first parameter is the receiver of the method call. | 74 * The first parameter is the receiver of the method call. |
|
regis
2012/10/25 02:27:56
What is the value of the first parameter when a No
Lasse Reichstein Nielsen
2012/10/25 06:17:35
Goooood question. Spec is silent on this.
For cons
regis
2012/10/25 17:47:16
That sounds reasonable. By 'this' value, you proba
| |
| 74 * The second parameter is the name of the called method. | 75 * The second parameter is the name of the called method. |
| 75 * The third parameter is the positional arguments that the method was | 76 * The third parameter is the positional arguments that the method was |
| 76 * called with. | 77 * called with. |
| 77 * The optional [exisitingArgumentNames] is the expected parameters of a | 78 * The optional [exisitingArgumentNames] is the expected parameters of a |
| 78 * method with the same name on the receiver, if available. This is | 79 * method with the same name on the receiver, if available. This is |
| 79 * the method that would have been called if the parameters had matched. | 80 * the method that would have been called if the parameters had matched. |
| 80 * | 81 * |
| 81 * TODO(lrn): This will be rewritten to use mirrors when they are available. | 82 * TODO(lrn): This will be rewritten to use mirrors when they are available. |
| 82 */ | 83 */ |
| 83 const NoSuchMethodError(Object this._receiver, | 84 const NoSuchMethodError(Object this._receiver, |
| 84 String this._functionName, | 85 String this._functionName, |
| 85 List this._arguments, | 86 List this._arguments, |
| 87 Map<String,Dynamic> this._namedArguments, | |
|
floitsch
2012/10/23 13:04:35
no need to type. the type comes from the field.
Lasse Reichstein Nielsen
2012/10/25 06:17:35
True. And dynamic is lower-case now.
| |
| 86 [List existingArgumentNames = null]) | 88 [List existingArgumentNames = null]) |
| 87 : this._existingArgumentNames = existingArgumentNames; | 89 : this._existingArgumentNames = existingArgumentNames; |
| 88 | 90 |
| 89 String toString() { | 91 String toString() { |
| 90 StringBuffer sb = new StringBuffer(); | 92 StringBuffer sb = new StringBuffer(); |
| 91 for (int i = 0; i < _arguments.length; i++) { | 93 int i = 0; |
| 92 if (i > 0) { | 94 if (_arguments != null) { |
| 93 sb.add(", "); | 95 for (; i < _arguments.length; i++) { |
| 96 if (i > 0) { | |
| 97 sb.add(", "); | |
| 98 } | |
| 99 sb.add(safeToString(_arguments[i])); | |
| 94 } | 100 } |
| 95 sb.add(safeToString(_arguments[i])); | 101 } |
| 102 if (_namedArguments != null) { | |
| 103 _namedArguments.forEach((String key, var value) { | |
| 104 if (i > 0) { | |
| 105 sb.add(", "); | |
| 106 } | |
| 107 sb.add(key); | |
| 108 sb.add(": "); | |
| 109 sb.add(safeToString(value)); | |
| 110 i++; | |
| 111 }); | |
| 96 } | 112 } |
| 97 if (_existingArgumentNames === null) { | 113 if (_existingArgumentNames === null) { |
| 98 return "NoSuchMethodError : method not found: '$_functionName'\n" | 114 return "NoSuchMethodError : method not found: '$_functionName'\n" |
| 99 "Receiver: ${safeToString(_receiver)}\n" | 115 "Receiver: ${safeToString(_receiver)}\n" |
| 100 "Arguments: [$sb]"; | 116 "Arguments: [$sb]"; |
| 101 } else { | 117 } else { |
| 102 String actualParameters = sb.toString(); | 118 String actualParameters = sb.toString(); |
| 103 sb = new StringBuffer(); | 119 sb = new StringBuffer(); |
| 104 for (int i = 0; i < _existingArgumentNames.length; i++) { | 120 for (int i = 0; i < _existingArgumentNames.length; i++) { |
| 105 if (i > 0) { | 121 if (i > 0) { |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 139 | 155 |
| 140 class OutOfMemoryError implements Error { | 156 class OutOfMemoryError implements Error { |
| 141 const OutOfMemoryError(); | 157 const OutOfMemoryError(); |
| 142 String toString() => "Out of Memory"; | 158 String toString() => "Out of Memory"; |
| 143 } | 159 } |
| 144 | 160 |
| 145 class StackOverflowError implements Error { | 161 class StackOverflowError implements Error { |
| 146 const StackOverflowError(); | 162 const StackOverflowError(); |
| 147 String toString() => "Stack Overflow"; | 163 String toString() => "Stack Overflow"; |
| 148 } | 164 } |
| OLD | NEW |