VR-Link API Documentation for HLA 1516
 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-2026 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) noexcept ;
41 
42  DtException(const DtString& errorMessage,
43  const DtException* previousException = 0) noexcept;
44 
48  DtException(const char *errorMessage,
49  const char *functionName,
50  const char *fileName,
51  unsigned int lineNumber,
52  const DtException *previousException = 0) noexcept;
53 
54  DtException(const DtString& errorMessage,
55  const char* functionName,
56  const DtString& fileName,
57  unsigned int lineNumber,
58  const DtException* previousException = 0) noexcept;
59 
61  DtException(const DtException& other) noexcept;
62 
64  DtException& operator=(const DtException& other) noexcept;
65 
67  virtual~DtException() noexcept;
68 
71  virtual const DtException *lastException() const noexcept;
72 
75  virtual const DtException& initialException() const noexcept;
76 
78  virtual const char* message() const noexcept;
79 
82  virtual DtString what() const noexcept;
83 
85  virtual DtString where() const noexcept;
86 
87 protected:
91 
92 };
93 
103 template <int I>
105 {
106 public:
107 
109  DtTemplatedException(const char *errorMessage,
110  const DtException *previousException = 0) noexcept
111  : DtException(errorMessage, previousException)
112  {}
113 
114  DtTemplatedException(const DtString& errorMessage,
115  const DtException* previousException = 0) noexcept
116  : DtException(errorMessage, previousException)
117  {}
118 
120  DtTemplatedException(const char *errorMessage,
121  const char *functionName,
122  const char *fileName,
123  unsigned int lineNumber,
124  const DtException *previousException = 0) noexcept
125  : DtException(errorMessage, functionName, fileName, lineNumber, previousException)
126  {}
127 
129  DtTemplatedException(const DtString& errorMessage,
130  const char* functionName,
131  const DtString& fileName,
132  unsigned int lineNumber,
133  const DtException* previousException = 0) noexcept
134  : DtException(errorMessage, functionName, fileName, lineNumber, previousException)
135  {}
136 
138  DtTemplatedException(const DtTemplatedException& other) noexcept : DtException(other)
139  {}
140 
143  {DtException::operator=(other); }
144 
145  virtual ~DtTemplatedException() noexcept{}
146 
147 private:
151  int retVal() const { return I;}
152 };
153 
156 const int DtInvalidInputNumber = ~0;
157 
160 
164 
167 
170 const int DtCorruptedStateNumber = ~2;
171 
174 
177 #ifndef __DtFUNC__
178 #if defined(__GNUC__)
179 #define __DtFUNC__ __PRETTY_FUNCTION__
180 #elif defined(_WIN32) && (_MSC_VER != 1200)
181 #define __DtFUNC__ __FUNCSIG__
182 #else
183 #define __DtFUNC__ "-Unknown Function-"
184 #endif
185 #endif /* __DtFUNC__ */
186 
189 #define DtTHROW_NEW(exceptionClass,errorMsg) \
190  throw exceptionClass(DtString(#exceptionClass": ") + (errorMsg), __DtFUNC__, DtFilename::stripPath(__FILE__), __LINE__, 0)
191 
193 #define DtTHROW_PROPAGATE(exceptionClass, errorMsg, exPtr) \
194  throw exceptionClass(DtString(#exceptionClass": ") + (errorMsg), __DtFUNC__, DtFilename::stripPath(__FILE__), __LINE__, exPtr)
195 
198 #define DtCATCH_AND_PROPAGATE(exceptionClass) \
199  catch( DtException &ex) \
200 {\
201  throw exceptionClass("Propagating DtException.", __DtFUNC__, DtFilename::stripPath(__FILE__).c_str(), __LINE__, &ex);\
202 }\
203  catch(std::exception &sexception)\
204 {\
205  DtString error("std::exception ");\
206  error += sexception.what();\
207  throw exceptionClass(error.c_str(), __DtFUNC__, DtFilename::stripPath(__FILE__).c_str(), __LINE__, 0); \
208 }\
209  catch(...)\
210 {\
211  throw DtUnknownException("Caught Unknown Exception.", __DtFUNC__, DtFilename::stripPath(__FILE__).c_str(), __LINE__, 0);\
212 }
213 
219 #define DtCATCH_AND_WARN(stream) \
220  catch (DtException &ex) \
221 { \
222  stream << "Caught DtException with stack: \n" << ex << std::endl; \
223 } \
224  catch (std::exception &sexception) \
225 {\
226  stream << "Caught std::exception: " << sexception.what() << std::endl; \
227 }\
228  catch (...) \
229 { \
230  stream << "Caught Unknown Exception in. " << __DtFUNC__ << "[" << DtFilename::stripPath(__FILE__) << ":" \
231  << __LINE__ << "]" << std::endl; \
232 }
233 
243 #define DtPROPAGATE(functionBody)\
244 { try\
245  functionBody\
246  DtCATCH_AND_PROPAGATE(DtCorruptedState)\
247 }
248 
251 DT_DLL_VLUTIL std::ostream & operator << (std::ostream &, const DtException &);
252 
254 
255 #ifdef DtUSE_UTILITIES_NAMESPACE
256 }
257 #endif
DtTemplatedException< DtInvalidInputNumber > DtInvalidInput
Definition: vlExceptions.h:159
DtTemplatedException(const DtString &errorMessage, const char *functionName, const DtString &fileName, unsigned int lineNumber, const DtException *previousException=0) noexcept
CTOR, exactly the same as the DtException CTOR.
Definition: vlExceptions.h:129
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:156
DtTemplatedException(const DtTemplatedException &other) noexcept
Copy CTOR.
Definition: vlExceptions.h:138
Contains the DtString class declaration.
DtException * myChainedException
Definition: vlExceptions.h:90
std::ostream & operator<<(std::ostream &os, const Dt3dChord &chord)
virtual ~DtTemplatedException() noexcept
Definition: vlExceptions.h:145
DtString myErrorMessage
Definition: vlExceptions.h:89
A Templated version of DtException.
Definition: vlExceptions.h:104
DtTemplatedException< DtCorruptedStateNumber > DtCorruptedState
Definition: vlExceptions.h:173
DtTemplatedException(const char *errorMessage, const char *functionName, const char *fileName, unsigned int lineNumber, const DtException *previousException=0) noexcept
CTOR, exactly the same as the DtException CTOR.
Definition: vlExceptions.h:120
DtTemplatedException< DtUnknownExceptionNumber > DtUnknownException
Definition: vlExceptions.h:166
int retVal() const
I believe that to make DtTemplateExceptions different types you have to use the template argument...
Definition: vlExceptions.h:151
DtString myLocationMessage
Definition: vlExceptions.h:88
DtTemplatedException & operator=(const DtTemplatedException &other) noexcept
Assignment Operator.
Definition: vlExceptions.h:142
const int DtCorruptedStateNumber
Thrown when an object&#39;s state is somehow corrupted.
Definition: vlExceptions.h:170
DtException & operator=(const DtException &other) noexcept
Assignment Operator.
DtTemplatedException(const DtString &errorMessage, const DtException *previousException=0) noexcept
Definition: vlExceptions.h:114
const int DtUnknownExceptionNumber
Thrown when an unknown exception was caught.
Definition: vlExceptions.h:163
Instances of DtString are used to represent strings.
Definition: vlString.h:38
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.
DtTemplatedException(const char *errorMessage, const DtException *previousException=0) noexcept
Default CTOR, exactly the same as the DtException CTOR.
Definition: vlExceptions.h:109
#define DT_DLL_VLUTIL
Definition: vlMachineTypes.h:121

Document ID: Generated on Mon Sep 28 00:09:32 EDT 2026 from SVN revision 295353
Copyright © 1992-2025 MAK Technologies. All Rights Reserved (www.mak.com)