OpenLexocad  27.0
Exception.h
Go to the documentation of this file.
1 #ifndef __EXCEPTION_H__
2 #define __EXCEPTION_H__
3 
4 //#include <Base/Base.h>
5 #include <Base/base_defines.h>
6 
7 #include <exception>
8 #include <string>
9 
10 
11 
12 #define THROW_CON_ERR_IF(_condition_, _msg_) \
13  if (_condition_) \
14  throw Base::ConstructionError(_msg_);
15 
16 #define THROW_FAIL_NDONE_IF(_condition_, _msg_) \
17  if (_condition_) \
18  throw Base::FailedNotDone(_msg_);
19 
20 namespace Base
21 {
23 {
24 public:
25  Exception(const char* sMessage, const char* detail);
26  Exception(void);
27  Exception(const Exception& inst);
28  virtual ~Exception() throw() {}
29 
30  Exception& operator=(const Exception& inst);
31 
32  virtual const char* what(void) const throw();
33  virtual const char* detail(void) const throw();
34 
35  void ReportException(void) const;
36 
37  inline void SetMessage(const char* sMessage);
38 
39 protected:
40 #ifdef _MSC_VER
41 #pragma warning(disable : 4251)
42 #endif
43  std::string _sErrMsg;
44  std::string _sErrDetail;
45 };
46 
47 
53 {
54 public:
56  AbortException(const char* sMessage);
60  AbortException(const AbortException& inst);
62  virtual ~AbortException() throw() {}
64  virtual const char* what() const throw();
65 };
66 
72 {
73 public:
77  MemoryException(const MemoryException& inst);
79  virtual ~MemoryException() throw() {}
80 };
81 
82 
83 inline void Exception::SetMessage(const char* sMessage)
84 {
85  _sErrMsg = sMessage;
86 }
87 
93 {
94 public:
96  ConstructionError(const char* sMessage);
102  virtual ~ConstructionError() throw() {}
104  virtual const char* what() const throw();
105 };
106 
111 {
112 public:
114  FailedNotDone(const char* sMessage);
116  FailedNotDone();
118  FailedNotDone(const FailedNotDone& inst);
120  virtual ~FailedNotDone() throw() {}
122  virtual const char* what() const throw();
123 };
124 
129 {
130 public:
132  ItemNotFound(const char* sMessage);
134  ItemNotFound();
136  ItemNotFound(const ItemNotFound& inst);
138  virtual ~ItemNotFound() throw() {}
140  virtual const char* what() const throw();
141 };
142 
147 {
148 public:
150  OutOfRange(const char* sMessage);
152  OutOfRange();
154  OutOfRange(const OutOfRange& inst);
156  virtual ~OutOfRange() throw() {}
158  virtual const char* what() const throw();
159 };
160 
165 {
166 public:
168  NotaNumber(const char* sMessage);
170  NotaNumber();
172  NotaNumber(const NotaNumber& inst);
174  virtual ~NotaNumber() throw() {}
176  virtual const char* what() const throw();
177 };
178 
183 {
184 public:
186  FileException(const char* sMessage);
188  FileException();
190  FileException(const FileException& inst);
192  virtual ~FileException() throw() {}
194  virtual const char* what() const throw();
195 };
196 
201 {
202 public:
204  VectorWithNullMagnitude(const char* sMessage);
210  virtual ~VectorWithNullMagnitude() throw() {}
212  virtual const char* what() const throw();
213 };
214 
219 {
220 public:
222  BadArguments(const char* sMessage);
224  BadArguments();
226  BadArguments(const BadArguments& inst);
228  virtual ~BadArguments() throw() {}
230  virtual const char* what() const throw();
231 };
232 
234 {
235 public:
236  GuidInUseException() { _sErrMsg = "GUID in use"; }
237 
238  GuidInUseException(const char* sMessage) : Base::Exception(sMessage, "") {}
239 };
240 
241 } // namespace Base
242 
243 
244 #if !defined No_Exception && !defined No_Standard_OutOfRange
245 #define OutOfRange_Raise_if(CONDITION, MESSAGE) \
246  if (CONDITION) \
247  throw Base::OutOfRange(MESSAGE);
248 #else
249 #define OutOfRange_Raise_if(CONDITION, MESSAGE)
250 #endif
251 
252 #if !defined No_Exception && !defined No_Standard_ConstructionError
253 #define ConstructionError_Raise_if(CONDITION, MESSAGE) \
254  if (CONDITION) \
255  throw Base::ConstructionError(MESSAGE);
256 #else
257 #define ConstructionError_Raise_if(CONDITION, MESSAGE)
258 #endif
259 
260 #if !defined No_Exception && !defined No_gp_VectorWithNullMagnitude
261 #define VectorWithNullMagnitude_Raise_if(CONDITION, MESSAGE) \
262  if (CONDITION) \
263  throw Base::VectorWithNullMagnitude(MESSAGE);
264 #else
265 #define VectorWithNullMagnitude_Raise_if(CONDITION, MESSAGE)
266 #endif
267 
268 #if !defined No_Exception
269 #define NotaNumber_if(CONDITION, MESSAGE) \
270  if (CONDITION) \
271  throw Base::NotaNumber(MESSAGE);
272 #else
273 #define NotaNumber_if(CONDITION, MESSAGE)
274 #endif
275 
276 
277 #endif // __EXCEPTION_H__
Definition: Exception.h:52
Definition: Exception.h:92
Definition: Exception.h:164
virtual ~MemoryException()
Destruction.
Definition: Exception.h:79
#define BASE_EXPORT
Definition: base_defines.h:12
virtual ~Exception()
Definition: Exception.h:28
virtual ~NotaNumber()
Destruction.
Definition: Exception.h:174
void SetMessage(const char *sMessage)
Definition: Exception.h:83
Definition: Exception.h:233
virtual ~AbortException()
Destruction.
Definition: Exception.h:62
std::string _sErrDetail
Definition: Exception.h:44
virtual ~FailedNotDone()
Destruction.
Definition: Exception.h:120
Definition: Exception.h:218
virtual ~FileException()
Destruction.
Definition: Exception.h:192
virtual ~ItemNotFound()
Destruction.
Definition: Exception.h:138
virtual ~BadArguments()
Destruction.
Definition: Exception.h:228
Definition: Exception.h:128
std::string _sErrMsg
Definition: Exception.h:43
virtual ~VectorWithNullMagnitude()
Destruction.
Definition: Exception.h:210
Definition: AbstractXMLReader.h:8
Definition: Exception.h:71
Definition: Exception.h:22
Definition: Exception.h:146
GuidInUseException()
Definition: Exception.h:236
virtual ~OutOfRange()
Destruction.
Definition: Exception.h:156
Definition: Exception.h:110
Definition: Exception.h:200
virtual ~ConstructionError()
Destruction.
Definition: Exception.h:102
GuidInUseException(const char *sMessage)
Definition: Exception.h:238
Definition: Exception.h:182