VR-Link API Documentation for DIS
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
vlExceptions.h
Go to the documentation of this file.
1 /*******************************************************************************
2 ** Copyright (c) 1992-2010 VT MAK
3 ** All rights reserved.
4 *******************************************************************************/
8 #pragma once
9 
10 #include "vlMachineTypes.h"
11 #include <exception>
12 #include "vlString.h"
13 #include "vlFilename.h"
14 #include <iosfwd>
15 
16 
17 #ifdef DtUSE_UTILITIES_NAMESPACE
18 namespace DtUSE_UTILITIES_NAMESPACE
19 {
20 #endif
21 
22 
34 {
35 public:
36 
39  DtException(const char *errorMessage,
40  const DtException *previousException = 0) throw() ;
41 
45  DtException(const char *errorMessage,
46  const char *functionName,
47  const char *fileName,
48  unsigned int lineNumber,
49  const DtException *previousException = 0) throw();
50 
52  DtException(const DtException& other) throw();
53 
55  DtException& operator=(const DtException& other) throw();
56 
58  virtual~DtException() throw();
59 
62  virtual const DtException *lastException() const throw();
63 
66  virtual const DtException& initialException() const throw();
67 
69  virtual const char* message() const throw();
70 
73  virtual DtString what() const throw();
74 
76  virtual DtString where() const throw();
77 
78 protected:
82 
83 };
84 
94 template <int I>
96 {
97 public:
98 
100  DtTemplatedException(const char *errorMessage,
101  const DtException *previousException = 0) throw():
102  DtException(errorMessage, previousException){}
103 
105  DtTemplatedException(const char *errorMessage,
106  const char *functionName,
107  const char *fileName,
108  unsigned int lineNumber,
109  const DtException *previousException = 0) throw():
110  DtException(errorMessage, functionName, fileName, lineNumber, previousException){}
111 
113  DtTemplatedException(const DtTemplatedException& other) throw() : DtException(other)
114  {}
115 
117  DtTemplatedException& operator=(const DtTemplatedException& other) throw()
118  {DtException::operator=(other); }
119 
120  virtual ~DtTemplatedException() throw(){}
121 
122 private:
126  int retVal() const { return I;}
127 };
128 
131 const int DtInvalidInputNumber = ~0;
132 
135 
139 
142 
145 const int DtCorruptedStateNumber = ~2;
146 
149 
152 #ifndef __DtFUNC__
153 #if defined(__GNUC__)
154 #define __DtFUNC__ __PRETTY_FUNCTION__
155 #elif defined(_WIN32) && (_MSC_VER != 1200)
156 #define __DtFUNC__ __FUNCSIG__
157 #else
158 #define __DtFUNC__ "-Unknown Function-"
159 #endif
160 #endif /* __DtFUNC__ */
161 
164 #define DtTHROW_NEW(exceptionClass,errorMsg) \
165  throw exceptionClass(DtString(#exceptionClass": ") + errorMsg, __DtFUNC__, DtFilename::stripPath(__FILE__), __LINE__, 0)
166 
168 #define DtTHROW_PROPAGATE(exceptionClass, errorMsg, exPtr) \
169  throw exceptionClass(DtString(#exceptionClass": ") + errorMsg, __DtFUNC__, DtFilename::stripPath(__FILE__), __LINE__, exPtr)
170 
173 #define DtCATCH_AND_PROPAGATE(exceptionClass) \
174  catch( DtException &ex) \
175 {\
176  throw exceptionClass("Propagating DtException.", __DtFUNC__, DtFilename::stripPath(__FILE__), __LINE__, &ex);\
177 }\
178  catch(std::exception &sexception)\
179 {\
180  DtString error("std::exception ");\
181  error += sexception.what();\
182  throw exceptionClass(error.c_str(), __DtFUNC__, DtFilename::stripPath(__FILE__), __LINE__, 0); \
183 }\
184  catch(...)\
185 {\
186  throw DtUnknownException("Caught Unknown Exception.", __DtFUNC__, DtFilename::stripPath(__FILE__), __LINE__, 0);\
187 }
188 
194 #define DtCATCH_AND_WARN(stream) \
195  catch (DtException &ex) \
196 { \
197  stream << "Caught DtException with stack: \n" << ex << std::endl; \
198 } \
199  catch (std::exception &sexception) \
200 {\
201  stream << "Caught std::exception: " << sexception.what() << std::endl; \
202 }\
203  catch (...) \
204 { \
205  stream << "Caught Unknown Exception in. " << __DtFUNC__ << "[" << DtFilename::stripPath(__FILE__) << ":" \
206  << __LINE__ << "]" << std::endl; \
207 }
208 
218 #define DtPROPAGATE(functionBody)\
219 { try\
220  functionBody\
221  DtCATCH_AND_PROPAGATE(DtCorruptedState)\
222 }
223 
226 DT_DLL_VLUTIL std::ostream & operator << (std::ostream &, const DtException &);
227 
229 
230 #ifdef DtUSE_UTILITIES_NAMESPACE
231 }
232 #endif

Document ID: Generated on Mon Apr 8 04:49:21 EDT 2019 from SVN revision 197403
Copyright © 2005-2016 VT MÄK. All Rights Reserved (www.mak.com)