| OLD | NEW |
| 1 part of dart.core; | 1 part of dart.core; |
| 2 class Error {Error(); | 2 class Error {Error(); |
| 3 static String safeToString(Object object) { | 3 static String safeToString(Object object) { |
| 4 if (object is num || object is bool || null == object) { | 4 if (object is num || object is bool || null == object) { |
| 5 return object.toString(); | 5 return object.toString(); |
| 6 } | 6 } |
| 7 if (object is String) { | 7 if (object is String) { |
| 8 return _stringToSafeString(object); | 8 return _stringToSafeString(object); |
| 9 } | 9 } |
| 10 return _objectToString(object); | 10 return _objectToString(object); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 if (start < 0 || start > length) { | 62 if (start < 0 || start > length) { |
| 63 if (startName == null) startName = "start"; | 63 if (startName == null) startName = "start"; |
| 64 throw new RangeError.range(start, 0, length, startName, message); | 64 throw new RangeError.range(start, 0, length, startName, message); |
| 65 } | 65 } |
| 66 if (end != null && (end < start || end > length)) { | 66 if (end != null && (end < start || end > length)) { |
| 67 if (endName == null) endName = "end"; | 67 if (endName == null) endName = "end"; |
| 68 throw new RangeError.range(end, start, length, endName, message); | 68 throw new RangeError.range(end, start, length, endName, message); |
| 69 } | 69 } |
| 70 } | 70 } |
| 71 static void checkNotNegative(int value, [String name, String message]) { | 71 static void checkNotNegative(int value, [String name, String message]) { |
| 72 if (value < 0) throw new RangeError.range(value, 0, null, name, message); | 72 if (value < 0) throw new RangeError.range(value, 0, ((__x3) => DDC$RT.cast(__x3,
Null, int, "CastLiteral", """line 320, column 57 of dart:core/errors.dart: """,
__x3 is int, true))(null), name, message); |
| 73 } | 73 } |
| 74 String toString() { | 74 String toString() { |
| 75 if (!_hasValue) return "RangeError: $message"; | 75 if (!_hasValue) return "RangeError: $message"; |
| 76 String value = Error.safeToString(invalidValue); | 76 String value = Error.safeToString(invalidValue); |
| 77 String explanation = ""; | 77 String explanation = ""; |
| 78 if (start == null) { | 78 if (start == null) { |
| 79 if (end != null) { | 79 if (end != null) { |
| 80 explanation = ": Not less than or equal to $end"; | 80 explanation = ": Not less than or equal to $end"; |
| 81 } | 81 } |
| 82 } | 82 } |
| 83 else if (end == null) { | 83 else if (end == null) { |
| 84 explanation = ": Not greater than or equal to $start"; | 84 explanation = ": Not greater than or equal to $start"; |
| 85 } | 85 } |
| 86 else if (end > start) { | 86 else if (end > start) { |
| 87 explanation = ": Not in range $start..$end, inclusive."; | 87 explanation = ": Not in range $start..$end, inclusive."; |
| 88 } | 88 } |
| 89 else if (end < start) { | 89 else if (end < start) { |
| 90 explanation = ": Valid value range is empty"; | 90 explanation = ": Valid value range is empty"; |
| 91 } | 91 } |
| 92 else { | 92 else { |
| 93 explanation = ": Only valid value is $start"; | 93 explanation = ": Only valid value is $start"; |
| 94 } | 94 } |
| 95 return "RangeError: $message ($value)$explanation"; | 95 return "RangeError: $message ($value)$explanation"; |
| 96 } | 96 } |
| 97 } | 97 } |
| 98 class IndexError extends ArgumentError implements RangeError {final indexable; | 98 class IndexError extends ArgumentError implements RangeError {final indexable; |
| 99 final int length; | 99 final int length; |
| 100 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"); | 100 IndexError(int invalidValue, indexable, [String name, String message, int lengt
h]) : this.indexable = indexable, this.length = ((__x4) => DDC$RT.cast(__x4, dyn
amic, int, "CastGeneral", """line 371, column 23 of dart:core/errors.dart: """,
__x4 is int, true))((length != null) ? length : indexable.length), super.value(i
nvalidValue, name, (message != null) ? message : "Index out of range"); |
| 101 int get start => 0; | 101 int get start => 0; |
| 102 int get end => length - 1; | 102 int get end => length - 1; |
| 103 String toString() { | 103 String toString() { |
| 104 assert (_hasValue); String target = Error.safeToString(indexable); | 104 assert (_hasValue); String target = Error.safeToString(indexable); |
| 105 var explanation = "index should be less than $length"; | 105 var explanation = "index should be less than $length"; |
| 106 if (invalidValue < 0) { | 106 if (invalidValue < 0) { |
| 107 explanation = "index must not be negative"; | 107 explanation = "index must not be negative"; |
| 108 } | 108 } |
| 109 return "RangeError: $message ($target[$invalidValue]): $explanation"; | 109 return "RangeError: $message ($target[$invalidValue]): $explanation"; |
| 110 } | 110 } |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 StackTrace get stackTrace => null; | 149 StackTrace get stackTrace => null; |
| 150 } | 150 } |
| 151 class StackOverflowError implements Error {const StackOverflowError(); | 151 class StackOverflowError implements Error {const StackOverflowError(); |
| 152 String toString() => "Stack Overflow"; | 152 String toString() => "Stack Overflow"; |
| 153 StackTrace get stackTrace => null; | 153 StackTrace get stackTrace => null; |
| 154 } | 154 } |
| 155 class CyclicInitializationError extends Error {final String variableName; | 155 class CyclicInitializationError extends Error {final String variableName; |
| 156 CyclicInitializationError([this.variableName]); | 156 CyclicInitializationError([this.variableName]); |
| 157 String toString() => variableName == null ? "Reading static variable during its
initialization" : "Reading static variable '$variableName' during its initializ
ation"; | 157 String toString() => variableName == null ? "Reading static variable during its
initialization" : "Reading static variable '$variableName' during its initializ
ation"; |
| 158 } | 158 } |
| OLD | NEW |