1 /**
2 * The exception module defines all system-level exceptions and provides a
3 * mechanism to alter system-level error handling.
4 *
5 * Copyright:
6 * Copyright (C) 2005-2006 Sean Kelly, Kris Bell.
7 * Some parts copyright (c) 2009-2016 dunnhumby Germany GmbH.
8 * All rights reserved.
9 *
10 * License:
11 * Tango Dual License: 3-Clause BSD License / Academic Free License v3.0.
12 * See LICENSE_TANGO.txt for details.
13 *
14 * Authors: Sean Kelly, Kris Bell
15 *
16 */
17 module ocean.core.ExceptionDefinitions;
18
19 import ocean.transition;
20
21 ////////////////////////////////////////////////////////////////////////////////
22 /*
23 - Exception
24 - OutOfMemoryException
25 - SwitchException
26 - AssertException
27 - ArrayBoundsException
28 - FinalizeException
29
30 - PlatformException
31 - ProcessException
32 - ThreadException
33 - FiberException
34 - ThreadPoolException
35 - SyncException
36 - IOException
37 - SocketException
38 - VfsException
39 - ClusterException
40
41 - NoSuchElementException
42 - CorruptedIteratorException
43
44 - IllegalArgumentException
45 - IllegalElementException
46
47 - TextException
48 - XmlException
49 - RegexException
50 - LocaleException
51 - UnicodeException
52
53 - PayloadException
54 */
55 ////////////////////////////////////////////////////////////////////////////////
56
57
58 public import core.exception;
59
60 import core.thread;
61 alias core.thread.ThreadException ThreadException;
62
63 /**
64 * Base class for operating system or library exceptions.
65 */
66 class PlatformException : Exception
67 {
68 this( istring msg, istring file = __FILE__, long line = __LINE__ )
69 {
70 super(msg, file, line);
71 }
72 }
73
74
75 /**
76 * Base class for ThreadPoolException
77 */
78 class ThreadPoolException : Exception
79 {
80 this( istring msg, istring file = __FILE__, long line = __LINE__ )
81 {
82 super(msg, file, line);
83 }
84 }
85
86
87 /**
88 * Base class for synchronization exceptions.
89 */
90 class SyncException : PlatformException
91 {
92 this( istring msg, istring file = __FILE__, long line = __LINE__ )
93 {
94 super(msg, file, line);
95 }
96 }
97
98
99
100 /**
101 * The basic exception thrown by the ocean.io package. One should try to ensure
102 * that all Tango exceptions related to IO are derived from this one.
103 */
104 class IOException : PlatformException
105 {
106 /*******************************************************************
107
108 Constructor
109
110 Params:
111 msg = message description of the error (uses stderr if empty)
112 file = file where exception is thrown
113 line = line where exception is thrown
114
115 *******************************************************************/
116
117 this( istring msg, istring file = __FILE__, long line = __LINE__ )
118 {
119 super(msg, file, line);
120 }
121
122 /*******************************************************************
123
124 Constructor
125
126 Params:
127 msg = message description of the error (uses stderr if empty)
128 error_num = error code
129 func_name = name of the method that failed
130 file = file where exception is thrown
131 line = line where exception is thrown
132
133 *******************************************************************/
134
135 public this ( istring msg, int error_num, istring func_name,
136 istring file = __FILE__, long line = __LINE__ )
137 {
138 super(msg, file, line);
139
140 this.error_num = error_num;
141 this.func_name = func_name;
142 this.line = line;
143 this.file = file;
144 }
145
146 /*******************************************************************
147
148 Error code
149
150 *******************************************************************/
151
152 protected int error_num;
153
154 /*******************************************************************
155
156 Last failed function name.
157
158 *******************************************************************/
159
160 protected istring func_name;
161
162 /*******************************************************************
163
164 Returns:
165 error code of the exception
166
167 *******************************************************************/
168
169 public int errorNumber ()
170 {
171 return this.error_num;
172 }
173
174 /*******************************************************************
175
176 Returns:
177 function name where the exception is thrown
178
179 *******************************************************************/
180
181 public istring failedFunctionName ()
182 {
183 return this.func_name;
184 }
185 }
186
187 /**
188 * The basic exception thrown by the ocean.io.vfs package.
189 */
190 class VfsException : IOException
191 {
192 this( istring msg, istring file = __FILE__, long line = __LINE__ )
193 {
194 super(msg, file, line);
195 }
196 }
197
198 /**
199 * The basic exception thrown by the ocean.io.cluster package.
200 */
201 class ClusterException : IOException
202 {
203 this( istring msg, istring file = __FILE__, long line = __LINE__ )
204 {
205 super(msg, file, line);
206 }
207 }
208
209 /**
210 * Base class for socket exceptions.
211 */
212 class SocketException : IOException
213 {
214 this( istring msg, istring file = __FILE__, long line = __LINE__ )
215 {
216 super(msg, file, line);
217 }
218 }
219
220
221 /**
222 * Base class for exception thrown by an InternetHost.
223 */
224 class HostException : IOException
225 {
226 this( istring msg, istring file = __FILE__, long line = __LINE__ )
227 {
228 super(msg, file, line);
229 }
230 }
231
232
233 /**
234 * Base class for exceptiond thrown by an Address.
235 */
236 class AddressException : IOException
237 {
238 this( istring msg, istring file = __FILE__, long line = __LINE__ )
239 {
240 super(msg, file, line);
241 }
242 }
243
244
245 /**
246 * Thrown when a socket failed to accept an incoming connection.
247 */
248 class SocketAcceptException : SocketException
249 {
250 this( istring msg, istring file = __FILE__, long line = __LINE__ )
251 {
252 super(msg, file, line);
253 }
254 }
255
256 /**
257 * Thrown on a process error.
258 */
259 class ProcessException : PlatformException
260 {
261 this( istring msg, istring file = __FILE__, long line = __LINE__ )
262 {
263 super(msg, file, line);
264 }
265 }
266
267
268 /**
269 * Represents a text processing error.
270 */
271 class TextException : Exception
272 {
273 this( istring msg, istring file = __FILE__, long line = __LINE__ )
274 {
275 super(msg, file, line);
276 }
277 }
278
279
280 /**
281 * Base class for regluar expression exceptions.
282 */
283 class RegexException : TextException
284 {
285 this( istring msg, istring file = __FILE__, long line = __LINE__ )
286 {
287 super(msg, file, line);
288 }
289 }
290
291
292 /**
293 * Base class for locale exceptions.
294 */
295 class LocaleException : TextException
296 {
297 this( istring msg, istring file = __FILE__, long line = __LINE__ )
298 {
299 super(msg, file, line);
300 }
301 }
302
303
304 /**
305 * Base class for XML exceptions.
306 */
307 class XmlException : TextException
308 {
309 this( istring msg, istring file = __FILE__, long line = __LINE__ )
310 {
311 super(msg, file, line);
312 }
313 }
314
315
316 /**
317 * RegistryException is thrown when the NetworkRegistry encounters a
318 * problem during proxy registration, or when it sees an unregistered
319 * guid.
320 */
321 class RegistryException : Exception
322 {
323 this( istring msg, istring file = __FILE__, long line = __LINE__ )
324 {
325 super(msg, file, line);
326 }
327 }
328
329
330 /**
331 * Thrown when an illegal argument is encountered.
332 */
333 class IllegalArgumentException : Exception
334 {
335 this( istring msg, istring file = __FILE__, long line = __LINE__ )
336 {
337 super(msg, file, line);
338 }
339 }
340
341
342 /**
343 *
344 * IllegalElementException is thrown by Collection methods
345 * that add (or replace) elements (and/or keys) when their
346 * arguments are null or do not pass screeners.
347 *
348 */
349 class IllegalElementException : IllegalArgumentException
350 {
351 this( istring msg, istring file = __FILE__, long line = __LINE__ )
352 {
353 super(msg, file, line);
354 }
355 }
356
357
358 /**
359 * Thrown on past-the-end errors by iterators and containers.
360 */
361 class NoSuchElementException : Exception
362 {
363 this( istring msg, istring file = __FILE__, long line = __LINE__ )
364 {
365 super(msg, file, line);
366 }
367 }
368
369
370 /**
371 * Thrown when a corrupt iterator is detected.
372 */
373 class CorruptedIteratorException : NoSuchElementException
374 {
375 this( istring msg, istring file = __FILE__, long line = __LINE__ )
376 {
377 super(msg, file, line);
378 }
379 }