| OLD | NEW |
| 1 part of dart.core; | 1 part of dart.core; |
| 2 | 2 class Error {Error(); |
| 3 class Error { | 3 static String safeToString(Object object) { |
| 4 Error(); | 4 if (object is num || object is bool || null == object) { |
| 5 static String safeToString(Object object) { | 5 return object.toString(); |
| 6 if (object is num || object is bool || null == object) { | |
| 7 return object.toString(); | |
| 8 } | 6 } |
| 9 if (object is String) { | 7 if (object is String) { |
| 10 return _stringToSafeString(object); | 8 return _stringToSafeString(object); |
| 11 } | 9 } |
| 12 return _objectToString(object); | 10 return _objectToString(object); |
| 13 } | 11 } |
| 14 static String _stringToSafeString(String string) { | 12 static String _stringToSafeString(String string) { |
| 15 return ((__x14) => DDC$RT.cast(__x14, dynamic, String, "CastGeneral", | 13 return ((__x14) => DDC$RT.cast(__x14, dynamic, String, "CastGeneral", """line
89, column 12 of dart:core/errors.dart: """, __x14 is String, true))(jsonEncodeN
ative(string)); |
| 16 """line 89, column 12 of dart:core/errors.dart: """, __x14 is String, | |
| 17 true))(jsonEncodeNative(string)); | |
| 18 } | 14 } |
| 19 static String _objectToString(Object object) { | 15 static String _objectToString(Object object) { |
| 20 return ((__x15) => DDC$RT.cast(__x15, dynamic, String, "CastGeneral", | 16 return ((__x15) => DDC$RT.cast(__x15, dynamic, String, "CastGeneral", """line
93, column 12 of dart:core/errors.dart: """, __x15 is String, true))(Primitives.
objectToString(object)); |
| 21 """line 93, column 12 of dart:core/errors.dart: """, __x15 is String, | |
| 22 true))(Primitives.objectToString(object)); | |
| 23 } | 17 } |
| 24 StackTrace get stackTrace => ((__x16) => DDC$RT.cast(__x16, dynamic, | 18 StackTrace get stackTrace => ((__x16) => DDC$RT.cast(__x16, dynamic, StackTrace
, "CastGeneral", """line 96, column 32 of dart:core/errors.dart: """, __x16 is S
tackTrace, true))(Primitives.extractStackTrace(this)); |
| 25 StackTrace, "CastGeneral", | 19 } |
| 26 """line 96, column 32 of dart:core/errors.dart: """, __x16 is StackTrace, | 20 class AssertionError extends Error {} |
| 27 true))(Primitives.extractStackTrace(this)); | 21 class TypeError extends AssertionError {} |
| 28 } | 22 class CastError extends Error {} |
| 29 class AssertionError extends Error {} | 23 class NullThrownError extends Error {String toString() => "Throw of null."; |
| 30 class TypeError extends AssertionError {} | 24 } |
| 31 class CastError extends Error {} | 25 class ArgumentError extends Error {final bool _hasValue; |
| 32 class NullThrownError extends Error { | 26 final invalidValue; |
| 33 String toString() => "Throw of null."; | 27 final String name; |
| 34 } | 28 final message; |
| 35 class ArgumentError extends Error { | 29 ArgumentError([this.message]) : invalidValue = null, _hasValue = false, name =
null; |
| 36 final bool _hasValue; | 30 ArgumentError.value(value, [String this.name, String this.message = "Invalid ar
gument"]) : invalidValue = value, _hasValue = true; |
| 37 final invalidValue; | 31 ArgumentError.notNull([String name]) : this.value(null, name, "Must not be null
"); |
| 38 final String name; | 32 String toString() { |
| 39 final message; | 33 if (!_hasValue) { |
| 40 ArgumentError([this.message]) | 34 var result = "Invalid arguments(s)"; |
| 41 : invalidValue = null, | 35 if (message != null) { |
| 42 _hasValue = false, | 36 result = "$result: $message"; |
| 43 name = null; | 37 } |
| 44 ArgumentError.value(value, | 38 return result; |
| 45 [String this.name, String this.message = "Invalid argument"]) | 39 } |
| 46 : invalidValue = value, | 40 String nameString = ""; |
| 47 _hasValue = true; | 41 if (name != null) { |
| 48 ArgumentError.notNull([String name]) | 42 nameString = " ($name)"; |
| 49 : this.value(null, name, "Must not be null"); | 43 } |
| 50 String toString() { | 44 return "$message$nameString: ${Error.safeToString(invalidValue)} |
| 51 if (!_hasValue) { | 45 "; |
| 52 var result = "Invalid arguments(s)"; | 46 } |
| 53 if (message != null) { | 47 } |
| 54 result = "$result: $message"; | 48 class RangeError extends ArgumentError {final num start; |
| 55 } | 49 final num end; |
| 56 return result; | 50 RangeError(var message) : start = null, end = null, super(message); |
| 57 } | 51 RangeError.value(num value, [String name, String message]) : start = null, end
= null, super.value(value, name, (message != null) ? message : "Value not in ran
ge"); |
| 58 String nameString = ""; | 52 RangeError.range(num invalidValue, int minValue, int maxValue, [String name, St
ring message]) : start = minValue, end = maxValue, super.value(invalidValue, nam
e, (message != null) ? message : "Invalid value"); |
| 59 if (name != null) { | 53 factory RangeError.index(int index, indexable, [String name, String message, in
t length]) = IndexError; |
| 60 nameString = " ($name)"; | 54 static void checkValueInInterval(int value, int minValue, int maxValue, [String
name, String message]) { |
| 61 } | 55 if (value < minValue || value > maxValue) { |
| 62 return "$message$nameString: ${Error.safeToString(invalidValue)}"; | 56 throw new RangeError.range(value, minValue, maxValue, name, message); |
| 63 } | 57 } |
| 64 } | 58 } |
| 65 class RangeError extends ArgumentError { | 59 static void checkValidIndex(int index, var indexable, [String name, int length,
String message]) { |
| 66 final num start; | 60 if (length == null) length = DDC$RT.cast(indexable.length, dynamic, int, "CastGe
neral", """line 285, column 34 of dart:core/errors.dart: """, indexable.length i
s int, true); |
| 67 final num end; | 61 if (index < 0 || index >= length) { |
| 68 RangeError(var message) | 62 if (name == null) name = "index"; |
| 69 : start = null, | 63 throw new RangeError.index(index, indexable, name, message, length); |
| 70 end = null, | 64 } |
| 71 super(message); | 65 } |
| 72 RangeError.value(num value, [String name, String message]) | 66 static void checkValidRange(int start, int end, int length, [String startName,
String endName, String message]) { |
| 73 : start = null, | 67 if (start < 0 || start > length) { |
| 74 end = null, | 68 if (startName == null) startName = "start"; |
| 75 super.value( | 69 throw new RangeError.range(start, 0, length, startName, message); |
| 76 value, name, (message != null) ? message : "Value not in range"); | 70 } |
| 77 RangeError.range(num invalidValue, int minValue, int maxValue, | 71 if (end != null && (end < start || end > length)) { |
| 78 [String name, String message]) | 72 if (endName == null) endName = "end"; |
| 79 : start = minValue, | 73 throw new RangeError.range(end, start, length, endName, message); |
| 80 end = maxValue, | 74 } |
| 81 super.value( | 75 } |
| 82 invalidValue, name, (message != null) ? message : "Invalid value"); | 76 static void checkNotNegative(int value, [String name, String message]) { |
| 83 factory RangeError.index(int index, indexable, | 77 if (value < 0) throw new RangeError.range(value, 0, null, name, message); |
| 84 [String name, String message, int length]) = IndexError; | 78 } |
| 85 static void checkValueInInterval(int value, int minValue, int maxValue, | 79 String toString() { |
| 86 [String name, String message]) { | 80 if (!_hasValue) return "RangeError: $message"; |
| 87 if (value < minValue || value > maxValue) { | 81 String value = Error.safeToString(invalidValue); |
| 88 throw new RangeError.range(value, minValue, maxValue, name, message); | 82 String explanation = ""; |
| 89 } | 83 if (start == null) { |
| 90 } | 84 if (end != null) { |
| 91 static void checkValidIndex(int index, var indexable, | 85 explanation = ": Not less than or equal to $end"; |
| 92 [String name, int length, String message]) { | 86 } |
| 93 if (length == null) length = DDC$RT.cast(indexable.length, dynamic, int, | 87 } |
| 94 "CastGeneral", """line 285, column 34 of dart:core/errors.dart: """, | 88 else if (end == null) { |
| 95 indexable.length is int, true); | 89 explanation = ": Not greater than or equal to $start"; |
| 96 if (index < 0 || index >= length) { | 90 } |
| 97 if (name == null) name = "index"; | 91 else if (end > start) { |
| 98 throw new RangeError.index(index, indexable, name, message, length); | 92 explanation = ": Not in range $start..$end, inclusive."; |
| 99 } | 93 } |
| 100 } | 94 else if (end < start) { |
| 101 static void checkValidRange(int start, int end, int length, | 95 explanation = ": Valid value range is empty"; |
| 102 [String startName, String endName, String message]) { | 96 } |
| 103 if (start < 0 || start > length) { | 97 else { |
| 104 if (startName == null) startName = "start"; | 98 explanation = ": Only valid value is $start"; |
| 105 throw new RangeError.range(start, 0, length, startName, message); | 99 } |
| 106 } | 100 return "RangeError: $message ($value)$explanation"; |
| 107 if (end != null && (end < start || end > length)) { | 101 } |
| 108 if (endName == null) endName = "end"; | 102 } |
| 109 throw new RangeError.range(end, start, length, endName, message); | 103 class IndexError extends ArgumentError implements RangeError {final indexable; |
| 110 } | 104 final int length; |
| 111 } | 105 IndexError(int invalidValue, indexable, [String name, String message, int lengt
h]) : this.indexable = indexable, this.length = (length != null) ? length : inde
xable.length, super.value(invalidValue, name, (message != null) ? message : "Ind
ex out of range"); |
| 112 static void checkNotNegative(int value, [String name, String message]) { | 106 int get start => 0; |
| 113 if (value < 0) throw new RangeError.range(value, 0, null, name, message); | 107 int get end => length - 1; |
| 114 } | 108 String toString() { |
| 115 String toString() { | 109 assert (_hasValue); String target = Error.safeToString(indexable); |
| 116 if (!_hasValue) return "RangeError: $message"; | 110 var explanation = "index should be less than $length"; |
| 117 String value = Error.safeToString(invalidValue); | 111 if (invalidValue < 0) { |
| 118 String explanation = ""; | 112 explanation = "index must not be negative"; |
| 119 if (start == null) { | 113 } |
| 120 if (end != null) { | 114 return "RangeError: $message ($target[$invalidValue]): $explanation"; |
| 121 explanation = ": Not less than or equal to $end"; | 115 } |
| 122 } | 116 } |
| 123 } else if (end == null) { | 117 class FallThroughError extends Error {FallThroughError(); |
| 124 explanation = ": Not greater than or equal to $start"; | 118 } |
| 125 } else if (end > start) { | 119 class AbstractClassInstantiationError extends Error {final String _className; |
| 126 explanation = ": Not in range $start..$end, inclusive."; | 120 AbstractClassInstantiationError(String this._className); |
| 127 } else if (end < start) { | 121 String toString() => "Cannot instantiate abstract class: '$_className'"; |
| 128 explanation = ": Valid value range is empty"; | 122 } |
| 129 } else { | 123 class NoSuchMethodError extends Error {final Object _receiver; |
| 130 explanation = ": Only valid value is $start"; | 124 final Symbol _memberName; |
| 131 } | 125 final List _arguments; |
| 132 return "RangeError: $message ($value)$explanation"; | 126 final Map<Symbol, dynamic> _namedArguments; |
| 133 } | 127 final List _existingArgumentNames; |
| 134 } | 128 NoSuchMethodError(Object receiver, Symbol memberName, List positionalArguments,
Map<Symbol, dynamic> namedArguments, [List existingArgumentNames = null]) : _re
ceiver = receiver, _memberName = memberName, _arguments = positionalArguments, _
namedArguments = namedArguments, _existingArgumentNames = existingArgumentNames; |
| 135 class IndexError extends ArgumentError implements RangeError { | 129 String toString() { |
| 136 final indexable; | 130 StringBuffer sb = new StringBuffer(); |
| 137 final int length; | 131 int i = 0; |
| 138 IndexError(int invalidValue, indexable, | 132 if (_arguments != null) { |
| 139 [String name, String message, int length]) | 133 for (; |
| 140 : this.indexable = indexable, | 134 i < _arguments.length; |
| 141 this.length = (length != null) ? length : indexable.length, | 135 i++) { |
| 142 super.value(invalidValue, name, | 136 if (i > 0) { |
| 143 (message != null) ? message : "Index out of range"); | 137 sb.write(", "); |
| 144 int get start => 0; | 138 } |
| 145 int get end => length - 1; | 139 sb.write(Error.safeToString(_arguments[i])); |
| 146 String toString() { | 140 } |
| 147 assert(_hasValue); | 141 } |
| 148 String target = Error.safeToString(indexable); | 142 if (_namedArguments != null) { |
| 149 var explanation = "index should be less than $length"; | 143 _namedArguments.forEach((Symbol key, var value) { |
| 150 if (invalidValue < 0) { | 144 if (i > 0) { |
| 151 explanation = "index must not be negative"; | 145 sb.write(", "); |
| 152 } | 146 } |
| 153 return "RangeError: $message ($target[$invalidValue]): $explanation"; | 147 sb.write(_symbolToString(key)); |
| 154 } | 148 sb.write(": "); |
| 155 } | 149 sb.write(Error.safeToString(value)); |
| 156 class FallThroughError extends Error { | 150 i++; |
| 157 FallThroughError(); | 151 } |
| 158 } | 152 ); |
| 159 class AbstractClassInstantiationError extends Error { | 153 } |
| 160 final String _className; | 154 if (_existingArgumentNames == null) { |
| 161 AbstractClassInstantiationError(String this._className); | 155 return "NoSuchMethodError : method not found: '$_memberName'\n" "Receiver: ${Err
or.safeToString(_receiver)} |
| 162 String toString() => "Cannot instantiate abstract class: '$_className'"; | 156 \n" "Arguments: [$sb]"; |
| 163 } | 157 } |
| 164 class NoSuchMethodError extends Error { | 158 else { |
| 165 final Object _receiver; | 159 String actualParameters = sb.toString(); |
| 166 final Symbol _memberName; | 160 sb = new StringBuffer(); |
| 167 final List _arguments; | 161 for (int i = 0; |
| 168 final Map<Symbol, dynamic> _namedArguments; | 162 i < _existingArgumentNames.length; |
| 169 final List _existingArgumentNames; | 163 i++) { |
| 170 NoSuchMethodError(Object receiver, Symbol memberName, | 164 if (i > 0) { |
| 171 List positionalArguments, Map<Symbol, dynamic> namedArguments, | 165 sb.write(", "); |
| 172 [List existingArgumentNames = null]) | 166 } |
| 173 : _receiver = receiver, | 167 sb.write(_existingArgumentNames[i]); |
| 174 _memberName = memberName, | 168 } |
| 175 _arguments = positionalArguments, | 169 String formalParameters = sb.toString(); |
| 176 _namedArguments = namedArguments, | 170 return "NoSuchMethodError: incorrect number of arguments passed to " "method na
med '$_memberName'\n" "Receiver: ${Error.safeToString(_receiver)} |
| 177 _existingArgumentNames = existingArgumentNames; | 171 \n" "Tried calling: $_memberName($actualParameters)\n" "Found: $_memberName($for
malParameters)"; |
| 178 String toString() { | 172 } |
| 179 StringBuffer sb = new StringBuffer(); | 173 } |
| 180 int i = 0; | 174 } |
| 181 if (_arguments != null) { | 175 class UnsupportedError extends Error {final String message; |
| 182 for (; i < _arguments.length; i++) { | 176 UnsupportedError(this.message); |
| 183 if (i > 0) { | 177 String toString() => "Unsupported operation: $message"; |
| 184 sb.write(", "); | 178 } |
| 185 } | 179 class UnimplementedError extends Error implements UnsupportedError {final Strin
g message; |
| 186 sb.write(Error.safeToString(_arguments[i])); | 180 UnimplementedError([String this.message]); |
| 187 } | 181 String toString() => (this.message != null ? "UnimplementedError: $message" : "
UnimplementedError"); |
| 188 } | 182 } |
| 189 if (_namedArguments != null) { | 183 class StateError extends Error {final String message; |
| 190 _namedArguments.forEach((Symbol key, var value) { | 184 StateError(this.message); |
| 191 if (i > 0) { | 185 String toString() => "Bad state: $message"; |
| 192 sb.write(", "); | 186 } |
| 193 } | 187 class ConcurrentModificationError extends Error {final Object modifiedObject; |
| 194 sb.write(_symbolToString(key)); | 188 ConcurrentModificationError([this.modifiedObject]); |
| 195 sb.write(": "); | 189 String toString() { |
| 196 sb.write(Error.safeToString(value)); | 190 if (modifiedObject == null) { |
| 197 i++; | 191 return "Concurrent modification during iteration."; |
| 198 }); | 192 } |
| 199 } | 193 return "Concurrent modification during iteration: " "${Error.safeToString(modif
iedObject)} |
| 200 if (_existingArgumentNames == null) { | 194 ."; |
| 201 return "NoSuchMethodError : method not found: '$_memberName'\n" "Receiver:
${Error.safeToString(_receiver)}\n" "Arguments: [$sb]"; | 195 } |
| 202 } else { | 196 } |
| 203 String actualParameters = sb.toString(); | 197 class OutOfMemoryError implements Error {const OutOfMemoryError(); |
| 204 sb = new StringBuffer(); | 198 String toString() => "Out of Memory"; |
| 205 for (int i = 0; i < _existingArgumentNames.length; i++) { | 199 StackTrace get stackTrace => null; |
| 206 if (i > 0) { | 200 } |
| 207 sb.write(", "); | 201 class StackOverflowError implements Error {const StackOverflowError(); |
| 208 } | 202 String toString() => "Stack Overflow"; |
| 209 sb.write(_existingArgumentNames[i]); | 203 StackTrace get stackTrace => null; |
| 210 } | 204 } |
| 211 String formalParameters = sb.toString(); | 205 class CyclicInitializationError extends Error {final String variableName; |
| 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)"; | 206 CyclicInitializationError([this.variableName]); |
| 213 } | 207 String toString() => variableName == null ? "Reading static variable during its
initialization" : "Reading static variable '$variableName' during its initializ
ation"; |
| 214 } | 208 } |
| 215 } | |
| 216 class UnsupportedError extends Error { | |
| 217 final String message; | |
| 218 UnsupportedError(this.message); | |
| 219 String toString() => "Unsupported operation: $message"; | |
| 220 } | |
| 221 class UnimplementedError extends Error implements UnsupportedError { | |
| 222 final String message; | |
| 223 UnimplementedError([String this.message]); | |
| 224 String toString() => (this.message != null | |
| 225 ? "UnimplementedError: $message" | |
| 226 : "UnimplementedError"); | |
| 227 } | |
| 228 class StateError extends Error { | |
| 229 final String message; | |
| 230 StateError(this.message); | |
| 231 String toString() => "Bad state: $message"; | |
| 232 } | |
| 233 class ConcurrentModificationError extends Error { | |
| 234 final Object modifiedObject; | |
| 235 ConcurrentModificationError([this.modifiedObject]); | |
| 236 String toString() { | |
| 237 if (modifiedObject == null) { | |
| 238 return "Concurrent modification during iteration."; | |
| 239 } | |
| 240 return "Concurrent modification during iteration: " "${Error.safeToString(mo
difiedObject)}."; | |
| 241 } | |
| 242 } | |
| 243 class OutOfMemoryError implements Error { | |
| 244 const OutOfMemoryError(); | |
| 245 String toString() => "Out of Memory"; | |
| 246 StackTrace get stackTrace => null; | |
| 247 } | |
| 248 class StackOverflowError implements Error { | |
| 249 const StackOverflowError(); | |
| 250 String toString() => "Stack Overflow"; | |
| 251 StackTrace get stackTrace => null; | |
| 252 } | |
| 253 class CyclicInitializationError extends Error { | |
| 254 final String variableName; | |
| 255 CyclicInitializationError([this.variableName]); | |
| 256 String toString() => variableName == null | |
| 257 ? "Reading static variable during its initialization" | |
| 258 : "Reading static variable '$variableName' during its initialization"; | |
| 259 } | |
| OLD | NEW |