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