Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(635)

Unified Diff: sdk/lib/collection/iterable.dart

Issue 262803003: Unify error messages for iterables and lists. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Capitalize messages. Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/lib/growable_array.dart ('k') | sdk/lib/internal/iterable.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/collection/iterable.dart
diff --git a/sdk/lib/collection/iterable.dart b/sdk/lib/collection/iterable.dart
index d74448aa099e7fadffe156d1aac1d5c28fff1327..7c8ec7039b66312b1cb6e8acfb32eb62b3b574ae 100644
--- a/sdk/lib/collection/iterable.dart
+++ b/sdk/lib/collection/iterable.dart
@@ -31,7 +31,7 @@ abstract class IterableMixin<E> implements Iterable<E> {
E reduce(E combine(E value, E element)) {
Iterator<E> iterator = this.iterator;
if (!iterator.moveNext()) {
- throw new StateError("No elements");
+ throw IterableElementError.noElement();
}
E value = iterator.current;
while (iterator.moveNext()) {
@@ -117,7 +117,7 @@ abstract class IterableMixin<E> implements Iterable<E> {
E get first {
Iterator it = iterator;
if (!it.moveNext()) {
- throw new StateError("No elements");
+ throw IterableElementError.noElement();
}
return it.current;
}
@@ -125,7 +125,7 @@ abstract class IterableMixin<E> implements Iterable<E> {
E get last {
Iterator it = iterator;
if (!it.moveNext()) {
- throw new StateError("No elements");
+ throw IterableElementError.noElement();
}
E result;
do {
@@ -136,9 +136,9 @@ abstract class IterableMixin<E> implements Iterable<E> {
E get single {
Iterator it = iterator;
- if (!it.moveNext()) throw new StateError("No elements");
+ if (!it.moveNext()) throw IterableElementError.noElement();
E result = it.current;
- if (it.moveNext()) throw new StateError("More than one element");
+ if (it.moveNext()) throw IterableElementError.tooMany();
return result;
}
@@ -147,7 +147,7 @@ abstract class IterableMixin<E> implements Iterable<E> {
if (test(element)) return element;
}
if (orElse != null) return orElse();
- throw new StateError("No matching element");
+ throw IterableElementError.noElement();
}
dynamic lastWhere(bool test(E value), { Object orElse() }) {
@@ -161,7 +161,7 @@ abstract class IterableMixin<E> implements Iterable<E> {
}
if (foundMatching) return result;
if (orElse != null) return orElse();
- throw new StateError("No matching element");
+ throw IterableElementError.noElement();
}
E singleWhere(bool test(E value)) {
@@ -170,14 +170,14 @@ abstract class IterableMixin<E> implements Iterable<E> {
for (E element in this) {
if (test(element)) {
if (foundMatching) {
- throw new StateError("More than one matching element");
+ throw IterableElementError.tooMany();
}
result = element;
foundMatching = true;
}
}
if (foundMatching) return result;
- throw new StateError("No matching element");
+ throw IterableElementError.noElement();
}
E elementAt(int index) {
@@ -225,7 +225,7 @@ abstract class IterableBase<E> implements Iterable<E> {
E reduce(E combine(E value, E element)) {
Iterator<E> iterator = this.iterator;
if (!iterator.moveNext()) {
- throw new StateError("No elements");
+ throw IterableElementError.noElement();
}
E value = iterator.current;
while (iterator.moveNext()) {
@@ -311,7 +311,7 @@ abstract class IterableBase<E> implements Iterable<E> {
E get first {
Iterator it = iterator;
if (!it.moveNext()) {
- throw new StateError("No elements");
+ throw IterableElementError.noElement();
}
return it.current;
}
@@ -319,7 +319,7 @@ abstract class IterableBase<E> implements Iterable<E> {
E get last {
Iterator it = iterator;
if (!it.moveNext()) {
- throw new StateError("No elements");
+ throw IterableElementError.noElement();
}
E result;
do {
@@ -330,9 +330,9 @@ abstract class IterableBase<E> implements Iterable<E> {
E get single {
Iterator it = iterator;
- if (!it.moveNext()) throw new StateError("No elements");
+ if (!it.moveNext()) throw IterableElementError.noElement();
E result = it.current;
- if (it.moveNext()) throw new StateError("More than one element");
+ if (it.moveNext()) throw IterableElementError.tooMany();
return result;
}
@@ -341,7 +341,7 @@ abstract class IterableBase<E> implements Iterable<E> {
if (test(element)) return element;
}
if (orElse != null) return orElse();
- throw new StateError("No matching element");
+ throw IterableElementError.noElement();
}
dynamic lastWhere(bool test(E value), { Object orElse() }) {
@@ -355,7 +355,7 @@ abstract class IterableBase<E> implements Iterable<E> {
}
if (foundMatching) return result;
if (orElse != null) return orElse();
- throw new StateError("No matching element");
+ throw IterableElementError.noElement();
}
E singleWhere(bool test(E value)) {
@@ -364,14 +364,14 @@ abstract class IterableBase<E> implements Iterable<E> {
for (E element in this) {
if (test(element)) {
if (foundMatching) {
- throw new StateError("More than one matching element");
+ throw IterableElementError.tooMany();
}
result = element;
foundMatching = true;
}
}
if (foundMatching) return result;
- throw new StateError("No matching element");
+ throw IterableElementError.noElement();
}
E elementAt(int index) {
« no previous file with comments | « runtime/lib/growable_array.dart ('k') | sdk/lib/internal/iterable.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698