Initial Patch of Auction House bot rev. 135
[auctionmangos.git] / dep / include / zthread / Exceptions.h
blobb7207932af4c40474a1559c75c3fc32c13f8ae17
1 /*
2 * Copyright (c) 2005, Eric Crahen
4 * Permission is hereby granted, free of charge, to any person obtaining a copy
5 * of this software and associated documentation files (the "Software"), to deal
6 * in the Software without restriction, including without limitation the rights
7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 * copies of the Software, and to permit persons to whom the Software is furnished
9 * to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice shall be included in all
12 * copies or substantial portions of the Software.
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
18 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
19 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 #ifndef __ZTEXCEPTIONS_H__
24 #define __ZTEXCEPTIONS_H__
27 #include "zthread/Config.h"
28 #include <string>
30 namespace ZThread {
32 /**
33 * @class Synchronization_Exception
35 * Serves as a general base class for the Exception hierarchy used within
36 * this package.
39 class Synchronization_Exception {
41 // Restrict heap allocation
42 static void * operator new(size_t size);
43 static void * operator new[](size_t size);
45 std::string _msg;
47 public:
49 /**
50 * Create a new exception with a default error message 'Synchronization
51 * Exception'
53 Synchronization_Exception() : _msg("Synchronization exception") { }
55 /**
56 * Create a new exception with a given error message
58 * @param const char* - error message
60 Synchronization_Exception(const char* msg) : _msg(msg) { }
62 /**
63 * Get additional info about the exception
65 * @return const char* for the error message
67 const char* what() const {
68 return _msg.c_str();
74 /**
75 * @class Interrupted_Exception
77 * Used to describe an interrupted operation that would have normally
78 * blocked the calling thread
80 class Interrupted_Exception : public Synchronization_Exception {
82 public:
84 //! Create a new exception
85 Interrupted_Exception() : Synchronization_Exception("Thread interrupted") { }
87 //! Create a new exception
88 Interrupted_Exception(const char* msg) : Synchronization_Exception(msg) { }
94 /**
95 * @class Deadlock_Exception
97 * Thrown when deadlock has been detected
99 class Deadlock_Exception : public Synchronization_Exception {
100 public:
102 //! Create a new exception
103 Deadlock_Exception() : Synchronization_Exception("Deadlock detected") { }
105 //! Create a new exception
106 Deadlock_Exception(const char* msg) : Synchronization_Exception(msg) { }
112 * @class InvalidOp_Exception
114 * Thrown when performing an illegal operation this object
116 class InvalidOp_Exception : public Synchronization_Exception {
117 public:
119 //! Create a new exception
120 InvalidOp_Exception() : Synchronization_Exception("Invalid operation") { }
121 //! Create a new exception
122 InvalidOp_Exception(const char* msg) : Synchronization_Exception(msg) { }
129 * @class Initialization_Exception
131 * Thrown when the system has no more resources to create new
132 * synchronization controls
134 class Initialization_Exception : public Synchronization_Exception {
136 public:
138 //! Create a new exception
139 Initialization_Exception() : Synchronization_Exception("Initialization error") { }
140 //! Create a new exception
141 Initialization_Exception(const char*msg) : Synchronization_Exception(msg) { }
146 * @class Cancellation_Exception
148 * Cancellation_Exceptions are thrown by 'Canceled' objects.
149 * @see Cancelable
151 class Cancellation_Exception : public Synchronization_Exception {
153 public:
155 //! Create a new Cancelltion_Exception
156 Cancellation_Exception() : Synchronization_Exception("Canceled") { }
157 //! Create a new Cancelltion_Exception
158 Cancellation_Exception(const char*msg) : Synchronization_Exception(msg) { }
164 * @class Timeout_Exception
166 * There is no need for error messaged simply indicates the last
167 * operation timed out
169 class Timeout_Exception : public Synchronization_Exception {
170 public:
172 //! Create a new Timeout_Exception
173 Timeout_Exception() : Synchronization_Exception("Timeout") { }
174 //! Create a new
175 Timeout_Exception(const char*msg) : Synchronization_Exception(msg) { }
180 * @class NoSuchElement_Exception
182 * The last operation that was attempted on a Queue could not find
183 * the item that was indicated (during that last Queue method invocation)
185 class NoSuchElement_Exception {
186 public:
188 //! Create a new exception
189 NoSuchElement_Exception() {}
194 * @class InvalidTask_Exception
196 * Thrown when a task is not valid (e.g. null or start()ing a thread with
197 * no overriden run() method)
199 class InvalidTask_Exception : public InvalidOp_Exception {
200 public:
202 //! Create a new exception
203 InvalidTask_Exception() : InvalidOp_Exception("Invalid task") {}
208 * @class BrokenBarrier_Exception
210 * Thrown when a Barrier is broken because one of the participating threads
211 * has been interrupted.
213 class BrokenBarrier_Exception : public Synchronization_Exception {
215 public:
217 //! Create a new exception
218 BrokenBarrier_Exception() : Synchronization_Exception("Barrier broken") { }
220 //! Create a new exception
221 BrokenBarrier_Exception(const char* msg) : Synchronization_Exception(msg) { }
226 * @class Future_Exception
228 * Thrown when there is an error using a Future.
230 class Future_Exception : public Synchronization_Exception {
232 public:
234 //! Create a new exception
235 Future_Exception() : Synchronization_Exception() { }
237 //! Create a new exception
238 Future_Exception(const char* msg) : Synchronization_Exception(msg) { }
244 #endif // __ZTEXCEPTIONS_H__