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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 RangeError(var message) : start = null, end = null, super(message); | 45 RangeError(var message) : start = null, end = null, super(message); |
46 RangeError.value(num value, [String name, String message]) : start = null, end
= null, super.value(value, name, (message != null) ? message : "Value not in ran
ge"); | 46 RangeError.value(num value, [String name, String message]) : start = null, end
= null, super.value(value, name, (message != null) ? message : "Value not in ran
ge"); |
47 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"); | 47 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"); |
48 factory RangeError.index(int index, indexable, [String name, String message, in
t length]) = IndexError; | 48 factory RangeError.index(int index, indexable, [String name, String message, in
t length]) = IndexError; |
49 static void checkValueInInterval(int value, int minValue, int maxValue, [String
name, String message]) { | 49 static void checkValueInInterval(int value, int minValue, int maxValue, [String
name, String message]) { |
50 if (value < minValue || value > maxValue) { | 50 if (value < minValue || value > maxValue) { |
51 throw new RangeError.range(value, minValue, maxValue, name, message); | 51 throw new RangeError.range(value, minValue, maxValue, name, message); |
52 } | 52 } |
53 } | 53 } |
54 static void checkValidIndex(int index, var indexable, [String name, int length,
String message]) { | 54 static void checkValidIndex(int index, var indexable, [String name, int length,
String message]) { |
55 if (length == null) length = DDC$RT.cast(indexable.length, dynamic, int, "CastGe
neral", """line 281, column 34 of dart:core/errors.dart: """, indexable.length i
s int, true); | 55 if (length == null) length = DEVC$RT.cast(indexable.length, dynamic, int, "CastG
eneral", """line 281, column 34 of dart:core/errors.dart: """, indexable.length
is int, true); |
56 if (index < 0 || index >= length) { | 56 if (index < 0 || index >= length) { |
57 if (name == null) name = "index"; | 57 if (name == null) name = "index"; |
58 throw new RangeError.index(index, indexable, name, message, length); | 58 throw new RangeError.index(index, indexable, name, message, length); |
59 } | 59 } |
60 } | 60 } |
61 static void checkValidRange(int start, int end, int length, [String startName,
String endName, String message]) { | 61 static void checkValidRange(int start, int end, int length, [String startName,
String endName, String message]) { |
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 } |
(...skipping 24 matching lines...) Expand all Loading... |
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 = ((__x3) => DDC$RT.cast(__x3, dyn
amic, int, "CastGeneral", """line 371, column 23 of dart:core/errors.dart: """,
__x3 is int, true))((length != null) ? length : indexable.length), super.value(i
nvalidValue, name, (message != null) ? message : "Index out of range"); | 100 IndexError(int invalidValue, indexable, [String name, String message, int lengt
h]) : this.indexable = indexable, this.length = ((__x3) => DEVC$RT.cast(__x3, dy
namic, int, "CastGeneral", """line 371, column 23 of dart:core/errors.dart: """,
__x3 is int, true))((length != null) ? length : indexable.length), super.value(
invalidValue, 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 |