| OLD | NEW |
| 1 part of dart.core; | 1 part of dart.core; |
| 2 | 2 |
| 3 class Error { | 3 class Error { |
| 4 Error(); | 4 Error(); |
| 5 static String safeToString(Object object) { | 5 static String safeToString(Object object) { |
| 6 if (object is num || object is bool || null == object) { | 6 if (object is num || object is bool || null == object) { |
| 7 return object.toString(); | 7 return object.toString(); |
| 8 } | 8 } |
| 9 if (object is String) { | 9 if (object is String) { |
| 10 return _stringToSafeString(object); | 10 return _stringToSafeString(object); |
| 11 } | 11 } |
| 12 return _objectToString(object); | 12 return _objectToString(object); |
| 13 } | 13 } |
| 14 static String _stringToSafeString(String string) { | 14 external static String _stringToSafeString(String string); |
| 15 return ((__x14) => DDC$RT.cast(__x14, dynamic, String, "CastGeneral", | 15 external static String _objectToString(Object object); |
| 16 """line 89, column 12 of dart:core/errors.dart: """, __x14 is String, | 16 external StackTrace get stackTrace; |
| 17 true))(jsonEncodeNative(string)); | |
| 18 } | |
| 19 static String _objectToString(Object object) { | |
| 20 return ((__x15) => DDC$RT.cast(__x15, dynamic, String, "CastGeneral", | |
| 21 """line 93, column 12 of dart:core/errors.dart: """, __x15 is String, | |
| 22 true))(Primitives.objectToString(object)); | |
| 23 } | |
| 24 StackTrace get stackTrace => ((__x16) => DDC$RT.cast(__x16, dynamic, | |
| 25 StackTrace, "CastGeneral", | |
| 26 """line 96, column 32 of dart:core/errors.dart: """, __x16 is StackTrace, | |
| 27 true))(Primitives.extractStackTrace(this)); | |
| 28 } | 17 } |
| 29 class AssertionError extends Error {} | 18 class AssertionError extends Error {} |
| 30 class TypeError extends AssertionError {} | 19 class TypeError extends AssertionError {} |
| 31 class CastError extends Error {} | 20 class CastError extends Error {} |
| 32 class NullThrownError extends Error { | 21 class NullThrownError extends Error { |
| 33 String toString() => "Throw of null."; | 22 String toString() => "Throw of null."; |
| 34 } | 23 } |
| 35 class ArgumentError extends Error { | 24 class ArgumentError extends Error { |
| 36 final bool _hasValue; | 25 final bool _hasValue; |
| 37 final invalidValue; | 26 final invalidValue; |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 [String name, String message, int length]) = IndexError; | 73 [String name, String message, int length]) = IndexError; |
| 85 static void checkValueInInterval(int value, int minValue, int maxValue, | 74 static void checkValueInInterval(int value, int minValue, int maxValue, |
| 86 [String name, String message]) { | 75 [String name, String message]) { |
| 87 if (value < minValue || value > maxValue) { | 76 if (value < minValue || value > maxValue) { |
| 88 throw new RangeError.range(value, minValue, maxValue, name, message); | 77 throw new RangeError.range(value, minValue, maxValue, name, message); |
| 89 } | 78 } |
| 90 } | 79 } |
| 91 static void checkValidIndex(int index, var indexable, | 80 static void checkValidIndex(int index, var indexable, |
| 92 [String name, int length, String message]) { | 81 [String name, int length, String message]) { |
| 93 if (length == null) length = DDC$RT.cast(indexable.length, dynamic, int, | 82 if (length == null) length = DDC$RT.cast(indexable.length, dynamic, int, |
| 94 "CastGeneral", """line 285, column 34 of dart:core/errors.dart: """, | 83 "CastGeneral", """line 281, column 34 of dart:core/errors.dart: """, |
| 95 indexable.length is int, true); | 84 indexable.length is int, true); |
| 96 if (index < 0 || index >= length) { | 85 if (index < 0 || index >= length) { |
| 97 if (name == null) name = "index"; | 86 if (name == null) name = "index"; |
| 98 throw new RangeError.index(index, indexable, name, message, length); | 87 throw new RangeError.index(index, indexable, name, message, length); |
| 99 } | 88 } |
| 100 } | 89 } |
| 101 static void checkValidRange(int start, int end, int length, | 90 static void checkValidRange(int start, int end, int length, |
| 102 [String startName, String endName, String message]) { | 91 [String startName, String endName, String message]) { |
| 103 if (start < 0 || start > length) { | 92 if (start < 0 || start > length) { |
| 104 if (startName == null) startName = "start"; | 93 if (startName == null) startName = "start"; |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 final Map<Symbol, dynamic> _namedArguments; | 157 final Map<Symbol, dynamic> _namedArguments; |
| 169 final List _existingArgumentNames; | 158 final List _existingArgumentNames; |
| 170 NoSuchMethodError(Object receiver, Symbol memberName, | 159 NoSuchMethodError(Object receiver, Symbol memberName, |
| 171 List positionalArguments, Map<Symbol, dynamic> namedArguments, | 160 List positionalArguments, Map<Symbol, dynamic> namedArguments, |
| 172 [List existingArgumentNames = null]) | 161 [List existingArgumentNames = null]) |
| 173 : _receiver = receiver, | 162 : _receiver = receiver, |
| 174 _memberName = memberName, | 163 _memberName = memberName, |
| 175 _arguments = positionalArguments, | 164 _arguments = positionalArguments, |
| 176 _namedArguments = namedArguments, | 165 _namedArguments = namedArguments, |
| 177 _existingArgumentNames = existingArgumentNames; | 166 _existingArgumentNames = existingArgumentNames; |
| 178 String toString() { | 167 external String toString(); |
| 179 StringBuffer sb = new StringBuffer(); | |
| 180 int i = 0; | |
| 181 if (_arguments != null) { | |
| 182 for (; i < _arguments.length; i++) { | |
| 183 if (i > 0) { | |
| 184 sb.write(", "); | |
| 185 } | |
| 186 sb.write(Error.safeToString(_arguments[i])); | |
| 187 } | |
| 188 } | |
| 189 if (_namedArguments != null) { | |
| 190 _namedArguments.forEach((Symbol key, var value) { | |
| 191 if (i > 0) { | |
| 192 sb.write(", "); | |
| 193 } | |
| 194 sb.write(_symbolToString(key)); | |
| 195 sb.write(": "); | |
| 196 sb.write(Error.safeToString(value)); | |
| 197 i++; | |
| 198 }); | |
| 199 } | |
| 200 if (_existingArgumentNames == null) { | |
| 201 return "NoSuchMethodError : method not found: '$_memberName'\n" "Receiver:
${Error.safeToString(_receiver)}\n" "Arguments: [$sb]"; | |
| 202 } else { | |
| 203 String actualParameters = sb.toString(); | |
| 204 sb = new StringBuffer(); | |
| 205 for (int i = 0; i < _existingArgumentNames.length; i++) { | |
| 206 if (i > 0) { | |
| 207 sb.write(", "); | |
| 208 } | |
| 209 sb.write(_existingArgumentNames[i]); | |
| 210 } | |
| 211 String formalParameters = sb.toString(); | |
| 212 return "NoSuchMethodError: incorrect number of arguments passed to " "meth
od named '$_memberName'\n" "Receiver: ${Error.safeToString(_receiver)}\n" "Tried
calling: $_memberName($actualParameters)\n" "Found: $_memberName($formalParamet
ers)"; | |
| 213 } | |
| 214 } | |
| 215 } | 168 } |
| 216 class UnsupportedError extends Error { | 169 class UnsupportedError extends Error { |
| 217 final String message; | 170 final String message; |
| 218 UnsupportedError(this.message); | 171 UnsupportedError(this.message); |
| 219 String toString() => "Unsupported operation: $message"; | 172 String toString() => "Unsupported operation: $message"; |
| 220 } | 173 } |
| 221 class UnimplementedError extends Error implements UnsupportedError { | 174 class UnimplementedError extends Error implements UnsupportedError { |
| 222 final String message; | 175 final String message; |
| 223 UnimplementedError([String this.message]); | 176 UnimplementedError([String this.message]); |
| 224 String toString() => (this.message != null | 177 String toString() => (this.message != null |
| (...skipping 25 matching lines...) Expand all Loading... |
| 250 String toString() => "Stack Overflow"; | 203 String toString() => "Stack Overflow"; |
| 251 StackTrace get stackTrace => null; | 204 StackTrace get stackTrace => null; |
| 252 } | 205 } |
| 253 class CyclicInitializationError extends Error { | 206 class CyclicInitializationError extends Error { |
| 254 final String variableName; | 207 final String variableName; |
| 255 CyclicInitializationError([this.variableName]); | 208 CyclicInitializationError([this.variableName]); |
| 256 String toString() => variableName == null | 209 String toString() => variableName == null |
| 257 ? "Reading static variable during its initialization" | 210 ? "Reading static variable during its initialization" |
| 258 : "Reading static variable '$variableName' during its initialization"; | 211 : "Reading static variable '$variableName' during its initialization"; |
| 259 } | 212 } |
| OLD | NEW |