VR-Link API Documentation for HLA 1.3
 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-2025 MAK Technologies, Inc
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 
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
DtTemplatedException< DtInvalidInputNumber > DtInvalidInput
Definition: vlExceptions.h:134
This file contains the declaration of DtFilename.
const int DtInvalidInputNumber
Thrown when an input parameter to a function or a CTOR was invalid.
Definition: vlExceptions.h:131
Contains the DtString class declaration.
DtException * myChainedException
Definition: vlExceptions.h:81
std::ostream & operator<<(std::ostream &os, const Dt3dChord &chord)
DtString myErrorMessage
Definition: vlExceptions.h:80
A Templated version of DtException.
Definition: vlExceptions.h:95
DtTemplatedException< DtCorruptedStateNumber > DtCorruptedState
Definition: vlExceptions.h:148
DtTemplatedException(const char *errorMessage, const char *functionName, const char *fileName, unsigned int lineNumber, const DtException *previousException=0)
CTOR, exactly the same as the DtException CTOR.
Definition: vlExceptions.h:105
DtTemplatedException< DtUnknownExceptionNumber > DtUnknownException
Definition: vlExceptions.h:141
int retVal() const
I believe that to make DtTemplateExceptions different types you have to use the template argument...
Definition: vlExceptions.h:126
DtString myLocationMessage
Definition: vlExceptions.h:79
DtException & operator=(const DtException &other)
Assignment Operator.
const int DtCorruptedStateNumber
Thrown when an object&#39;s state is somehow corrupted.
Definition: vlExceptions.h:145
DtTemplatedException(const char *errorMessage, const DtException *previousException=0)
Default CTOR, exactly the same as the DtException CTOR.
Definition: vlExceptions.h:100
virtual ~DtTemplatedException()
Definition: vlExceptions.h:120
DtTemplatedException & operator=(const DtTemplatedException &other)
Assignment Operator.
Definition: vlExceptions.h:117
DtTemplatedException(const DtTemplatedException &other)
Copy CTOR.
Definition: vlExceptions.h:113
const int DtUnknownExceptionNumber
Thrown when an unknown exception was caught.
Definition: vlExceptions.h:138
Instances of DtString are used to represent strings.
Definition: vlString.h:36
DtException is the generic MAK Exception from which all other Exceptions thrown by MAK products are d...
Definition: vlExceptions.h:33
This file contains typedefs for machine dependant types.
#define DT_DLL_VLUTIL
Definition: vlMachineTypes.h:109

Document ID: Generated on Thu Oct 16 00:12:25 EDT 2025 from SVN revision 280738
Copyright © 1992-2025 MAK Technologies. All Rights Reserved (www.mak.com)