New test.
[mono.git] / mcs / class / Mono.C5 / C5 / Exceptions.cs
1 #if NET_2_0
2 /*\r
3  Copyright (c) 2003-2006 Niels Kokholm and Peter Sestoft\r
4  Permission is hereby granted, free of charge, to any person obtaining a copy\r
5  of this software and associated documentation files (the "Software"), to deal\r
6  in the Software without restriction, including without limitation the rights\r
7  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r
8  copies of the Software, and to permit persons to whom the Software is\r
9  furnished to do so, subject to the following conditions:\r
10  \r
11  The above copyright notice and this permission notice shall be included in\r
12  all copies or substantial portions of the Software.\r
13  \r
14  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r
15  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r
16  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r
17  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r
18  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r
19  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\r
20  SOFTWARE.\r
21 */\r
22 \r
23 using System;\r
24 using System.Diagnostics;\r
25 using SCG = System.Collections.Generic;\r
26 \r
27 namespace C5\r
28 {\r
29   /// <summary>\r
30   /// An exception to throw from library code when an internal inconsistency is encountered.\r
31   /// </summary>\r
32   public class InternalException : Exception\r
33   {\r
34     internal InternalException(string message) : base(message) { }\r
35   }\r
36 \r
37   /// <summary>\r
38   /// An exception thrown by an update operation on a Read-Only collection or dictionary.\r
39   /// <para>This exception will be thrown unconditionally when an update operation \r
40   /// (method or set property) is called. No check is made to see if the update operation, \r
41   /// if allowed, would actually change the collection. </para>\r
42   /// </summary>\r
43   [Serializable]\r
44   public class ReadOnlyCollectionException : Exception\r
45   {\r
46     /// <summary>\r
47     /// Create a simple exception with no further explanation.\r
48     /// </summary>\r
49     public ReadOnlyCollectionException() : base() { }\r
50     /// <summary>\r
51     /// Create the exception with an explanation of the reason.\r
52     /// </summary>\r
53     /// <param name="message"></param>\r
54     public ReadOnlyCollectionException(string message) : base(message) { }\r
55   }\r
56 \r
57   /// <summary>\r
58   /// \r
59   /// </summary>\r
60   [Serializable]\r
61   public class FixedSizeCollectionException : Exception\r
62   {\r
63     /// <summary>\r
64     /// Create a simple exception with no further explanation.\r
65     /// </summary>\r
66     public FixedSizeCollectionException() : base() { }\r
67     /// <summary>\r
68     /// Create the exception with an explanation of the reason.\r
69     /// </summary>\r
70     /// <param name="message"></param>\r
71     public FixedSizeCollectionException(string message) : base(message) { }\r
72   }\r
73 \r
74   /// <summary>\r
75   /// \r
76   /// </summary>\r
77   [Serializable]\r
78   public class UnlistenableEventException : Exception\r
79   {\r
80     /// <summary>\r
81     /// Create a simple exception with no further explanation.\r
82     /// </summary>\r
83     public UnlistenableEventException() : base() { }\r
84     /// <summary>\r
85     /// Create the exception with an explanation of the reason.\r
86     /// </summary>\r
87     /// <param name="message"></param>\r
88     public UnlistenableEventException(string message) : base(message) { }\r
89   }\r
90 \r
91   /// <summary>\r
92   /// An exception thrown by enumerators, range views etc. when accessed after \r
93   /// the underlying collection has been modified.\r
94   /// </summary>\r
95   [Serializable]\r
96   public class CollectionModifiedException : Exception\r
97   {\r
98     /// <summary>\r
99     /// Create a simple exception with no further explanation.\r
100     /// </summary>\r
101     public CollectionModifiedException() : base() { }\r
102     /// <summary>\r
103     /// Create the exception with an explanation of the reason.\r
104     /// </summary>\r
105     /// <param name="message"></param>\r
106     public CollectionModifiedException(string message) : base(message) { }\r
107   }\r
108 \r
109   /// <summary>\r
110   /// An excption thrown when trying to access a view (a list view on a <see cref="T:C5.IList`1"/> or \r
111   /// a snapshot on a <see cref="T:C5.IPersistentSorted`1"/>)\r
112   /// that has been invalidated by some earlier operation.\r
113   /// <para>\r
114   /// The typical scenario is a view on a list that hash been invalidated by a call to \r
115   /// Sort, Reverse or Shuffle on some other, overlapping view or the whole list.\r
116   /// </para>\r
117   /// </summary>\r
118   [Serializable]\r
119   public class ViewDisposedException : Exception\r
120   {\r
121     /// <summary>\r
122     /// Create a simple exception with no further explanation.\r
123     /// </summary>\r
124     public ViewDisposedException() : base() { }\r
125     /// <summary>\r
126     /// Create the exception with an explanation of the reason.\r
127     /// </summary>\r
128     /// <param name="message"></param>\r
129     public ViewDisposedException(string message) : base(message) { }\r
130   }\r
131 \r
132   /// <summary>\r
133   /// An exception thrown by a lookup or lookup with update operation that does not \r
134   /// find the lookup item and has no other means to communicate failure.\r
135   /// <para>The typical scenario is a lookup by key in a dictionary with an indexer,\r
136   /// see e.g. <see cref="P:C5.IDictionary`2.Item(`0)"/></para>\r
137   /// </summary>\r
138   [Serializable]\r
139   public class NoSuchItemException : Exception\r
140   {\r
141     /// <summary>\r
142     /// Create a simple exception with no further explanation.\r
143     /// </summary>\r
144     public NoSuchItemException() : base() { }\r
145     /// <summary>\r
146     /// Create the exception with an explanation of the reason.\r
147     /// </summary>\r
148     /// <param name="message"></param>\r
149     public NoSuchItemException(string message) : base(message) { }\r
150   }\r
151 \r
152   /// <summary>\r
153   /// An exception thrown by an operation on a list (<see cref="T:C5.IList`1"/>)\r
154   /// that only makes sense for a view, not for an underlying list.\r
155   /// </summary>\r
156   [Serializable]\r
157   public class NotAViewException : Exception\r
158   {\r
159     /// <summary>\r
160     /// Create a simple exception with no further explanation.\r
161     /// </summary>\r
162     public NotAViewException() : base() { }\r
163     /// <summary>\r
164     /// Create the exception with an explanation of the reason.\r
165     /// </summary>\r
166     /// <param name="message"></param>\r
167     public NotAViewException(string message) : base(message) { }\r
168   }\r
169 \r
170   /// <summary>\r
171   /// An exception thrown when an operation attempts to create a duplicate in a collection with set semantics \r
172   /// (<see cref="P:C5.IExtensible`1.AllowsDuplicates"/> is false) or attempts to create a duplicate key in a dictionary.\r
173   /// <para>With collections this can only happen with Insert operations on lists, since the Add operations will\r
174   /// not try to create duplictes and either ignore the failure or report it in a bool return value.\r
175   /// </para>\r
176   /// <para>With dictionaries this can happen with the <see cref="M:C5.IDictionary`2.Add(`0,`1)"/> metod.</para>\r
177   /// </summary>\r
178   [Serializable]\r
179   public class DuplicateNotAllowedException : Exception\r
180   {\r
181     /// <summary>\r
182     /// Create a simple exception with no further explanation.\r
183     /// </summary>\r
184     public DuplicateNotAllowedException() : base() { }\r
185     /// <summary>\r
186     /// Create the exception with an explanation of the reason.\r
187     /// </summary>\r
188     /// <param name="message"></param>\r
189     public DuplicateNotAllowedException(string message) : base(message) { }\r
190   }\r
191 \r
192   /// <summary>\r
193   /// \r
194   /// </summary>\r
195   [Serializable]\r
196   public class InvalidPriorityQueueHandleException : Exception\r
197   {\r
198     /// <summary>\r
199     /// Create a simple exception with no further explanation.\r
200     /// </summary>\r
201     public InvalidPriorityQueueHandleException() : base() { }\r
202     /// <summary>\r
203     /// Create the exception with an explanation of the reason.\r
204     /// </summary>\r
205     /// <param name="message"></param>\r
206     public InvalidPriorityQueueHandleException(string message) : base(message) { }\r
207   }\r
208 \r
209   /// <summary>\r
210   /// An exception thrown by an operation that need to construct a natural\r
211   /// comparer for a type.\r
212   /// </summary>\r
213   [Serializable]\r
214   public class NotComparableException : Exception\r
215   {\r
216     /// <summary>\r
217     /// Create a simple exception with no further explanation.\r
218     /// </summary>\r
219     public NotComparableException() : base() { }\r
220     /// <summary>\r
221     /// Create the exception with an explanation of the reason.\r
222     /// </summary>\r
223     /// <param name="message"></param>\r
224     public NotComparableException(string message) : base(message) { }\r
225   }\r
226 \r
227   /// <summary>\r
228   /// An exception thrown by operations on a list that expects an argument\r
229   /// that is a view on the same underlying list.\r
230   /// </summary>\r
231   [Serializable]\r
232   public class IncompatibleViewException : Exception\r
233   {\r
234     /// <summary>\r
235     /// Create a simple exception with no further explanation.\r
236     /// </summary>\r
237     public IncompatibleViewException() : base() { }\r
238     /// <summary>\r
239     /// Create the exception with an explanation of the reason.\r
240     /// </summary>\r
241     /// <param name="message"></param>\r
242     public IncompatibleViewException(string message) : base(message) { }\r
243   }\r
244 \r
245 }
246 #endif