Open Inventor Reference
SoCatch.h
Go to the documentation of this file.
1 // **InsertLicense** code
2 
3 #ifndef _SO_CATCH_
4 #define _SO_CATCH_
5 
8 #include <Inventor/SbString.h>
10 
17 
19 {
20  public:
21 
25 
28  static void enableExceptionHandling(bool on);
29 
31  static void initClass();
32 
63  static void postExceptionMessage(SoType ERR_OBJ_TYPE_ID,
64  const char *OP_DESCR_STR,
65  SoType ACTION_TYPE_ID,
66  const char *END_STR);
67 
68  private:
69 
72  static bool _isExceptionHandlingEnabled;
73 
74 };
75 
76 #if !defined(DISABLE_ERRORTRACING)
77 
79 #define SO_CATCH_START \
80  if (!SoCatch::isExceptionHandlingEnabled()) {
81 
82 
91 #define SO_CATCH_ELSE(CODE_BEFORE_TRY) \
92  } \
93  else { \
94  CODE_BEFORE_TRY \
95  try {
96 
97 
161 #define SO_CATCH_END(ERR_OBJ_TYPE_ID, OP_DESCR_STR, ACTION_TYPE_ID, END_STR) \
162  } \
163  catch(...) { \
164  /* Bad case, we caught a crash. Compose */ \
165  /* the error string and post it to SoError. */ \
166  try { \
167  /* Do extra save message posting since we must */ \
168  /* assume that passed parameters (which could */ \
169  /* be expressions) also could be corrupt. */ \
170  SoCatch::postExceptionMessage(ERR_OBJ_TYPE_ID, \
171  OP_DESCR_STR, \
172  ACTION_TYPE_ID, \
173  END_STR); \
174  } \
175  catch(...) { \
176  SoError::post("<Could not create error message " \
177  "after catching fatal error>"); \
178  } \
179  } /* catch(...) */ \
180  } /* else of SO_CATCH_ELSE */
181 
182 #else // DISABLE_ERRORTRACING
183 
184 #define SO_CATCH_START \
185  if(1) {
186 #define SO_CATCH_ELSE(CODE_BEFORE_TRY) \
187  } \
188  else {
189 #define SO_CATCH_END(ERR_OBJ_TYPE_ID, OP_DESCR_STR, ACTION_TYPE_ID, END_STR) \
190  }
191 
192 #endif // DISABLE_ERRORTRACING
193 
194 #endif // _SO_CATCH_
#define INVENTOR_API
Disable some annoying warnings on MSVC 6.
Definition: SbSystem.h:81
Class containing static functions to control global exception handling for OpenInventor.
Definition: SoCatch.h:19
static void postExceptionMessage(SoType ERR_OBJ_TYPE_ID, const char *OP_DESCR_STR, SoType ACTION_TYPE_ID, const char *END_STR)
Posts composed error message.
static void initClass()
Initializes the SoCatch class.
static void enableExceptionHandling(bool on)
Function to enabled/disable exception handling for all SO_CATCH* macros when passing TRUE/FALSE.
static bool isExceptionHandlingEnabled()
Function to query exception handling for all SO_CATCH* macros.
SoType has no virtual functions to keep it small...
Definition: SoType.h:103