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

Unified Diff: sdk/lib/internal/list.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 | « sdk/lib/internal/iterable.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/internal/list.dart
diff --git a/sdk/lib/internal/list.dart b/sdk/lib/internal/list.dart
index f40c39bffaeee7fa1076ac781f5cd17bca242912..473a87a622cc8b947c3b208c4928a84ef18fa85f 100644
--- a/sdk/lib/internal/list.dart
+++ b/sdk/lib/internal/list.dart
@@ -307,6 +307,49 @@ class ReversedListIterable<E> extends ListIterable<E> {
}
/**
+ * Creates errors thrown by unmodifiable lists when they are attempted modified.
+ *
+ * This class creates [UnsupportedError]s with specialized messages.
+ */
+abstract class UnmodifiableListError {
+ /** Error thrown when trying to add elements to an unmodifiable list. */
+ static UnsupportedError add()
+ => new UnsupportedError("Cannot add to unmodifiable List");
+
+ /** Error thrown when trying to add elements to an unmodifiable list. */
+ static UnsupportedError change()
+ => new UnsupportedError(
+ "Cannot change the content of an unmodifiable List");
+
+ /** Error thrown when trying to change the length of an unmodifiable list. */
+ static UnsupportedError length()
+ => new UnsupportedError("Cannot change length of unmodifiable List");
+
+ /** Error thrown when trying to remove elements from an unmodifiable list. */
+ static UnsupportedError remove()
+ => new UnsupportedError("Cannot remove from unmodifiable List");
+}
+
+/**
+ * Creates errors thrown by non-growable lists when they are attempted modified.
+ *
+ * This class creates [UnsupportedError]s with specialized messages.
+ */
+abstract class NonGrowableListError {
+ /** Error thrown when trying to add elements to an non-growable list. */
+ static UnsupportedError add()
+ => new UnsupportedError("Cannot add to non-growable List");
+
+ /** Error thrown when trying to change the length of an non-growable list. */
+ static UnsupportedError length()
+ => new UnsupportedError("Cannot change length of non-growable List");
+
+ /** Error thrown when trying to remove elements from an non-growable list. */
+ static UnsupportedError remove()
+ => new UnsupportedError("Cannot remove from non-growable List");
+}
+
+/**
* Converts a growable list to a fixed length list with the same elements.
*
* For internal use only.
« no previous file with comments | « sdk/lib/internal/iterable.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698