00001
00021 #ifndef INC_MI32_MIEXCEPT_H
00022 #define INC_MI32_MIEXCEPT_H
00023
00024 class MIEXCEPTION {
00025 public:
00026
00027
00028
00030 MIEXCEPTION (
00031 const int ErrorCode,
00032 const int LineNum,
00033 const char*const RcsID
00034 );
00035
00037 virtual ~MIEXCEPTION (
00038 );
00039
00040 #ifndef GENERATING_DOXYGEN_OUTPUT
00044 #endif
00045
00047 void AddSourceLine (
00048 const char*const rcsid,
00049 const int LineNum
00050 );
00051
00053 int GetErrorCode (
00054 );
00055
00056 #ifndef GENERATING_DOXYGEN_OUTPUT
00060
00064 #endif
00065
00066 protected:
00067
00069 virtual int GenerateErrorCode (
00070 );
00071
00072 private:
00073 #ifndef GENERATING_DOXYGEN_OUTPUT
00074
00078
00079 int ErrCode;
00080 int LineRepeatCount;
00081 int LastLineNum;
00082
00083
00084
00085 #if defined(WINNT)
00086 #pragma warning (push)
00087 #pragma warning (disable:4251)
00088 #endif
00089
00091
00092 #if defined(WINNT)
00093 #pragma warning (pop)
00094 #endif
00095 #endif // GENERATING_DOXYGEN_OUTPUT
00096 };
00097
00098
00099 #if defined(WINNT) && defined(_CPPUNWIND)
00100
00101 #include <exception>
00102
00103 #define MITRY try
00104 #define MICATCH catch
00105
00106 #define MICATCHRETURN \
00107 catch(MIEXCEPTION& ex) { \
00108 return (SetErrPosnExc(ex)); \
00109 } \
00110 catch(std::bad_alloc& ex) { \
00111 return (SetErrPosnC(EOutOfMemoryB)); \
00112 }
00113
00114 #define MICATCHSETERR \
00115 catch(MIEXCEPTION& ex) { \
00116 err = SetErrPosnExc(ex); \
00117 } \
00118 catch(std::bad_alloc& ex) { \
00119 err = SetErrPosnC(EOutOfMemoryB); \
00120 }
00121
00122 #define MICATCHGOTO \
00123 catch(MIEXCEPTION& ex) { \
00124 err = SetErrPosnExc(ex); \
00125 goto Error; \
00126 } \
00127 catch(std::bad_alloc& ex) { \
00128 err = SetErrPosnC(EOutOfMemoryB); \
00129 goto Error; \
00130 }
00131
00132 #define MICATCHDISPLAY(_w_) \
00133 catch(MIEXCEPTION& ex) { \
00134 MdlgDisplayErrorCode(_w_, ex); \
00135 } \
00136 catch(std::bad_alloc& ex) { \
00137 MdlgDisplayErrorCode(_w_, EOutOfMemoryB); \
00138 }
00139
00140 #define MICATCHDISPLAYRETURN(_w_) \
00141 catch(MIEXCEPTION& ex) { \
00142 MdlgDisplayErrorCode(_w_, ex); \
00143 return; \
00144 } \
00145 catch(std::bad_alloc& ex) { \
00146 MdlgDisplayErrorCode(_w_, EOutOfMemoryB); \
00147 return; \
00148 }
00149
00150 #define MICATCHIGNORE \
00151 catch(MIEXCEPTION& ex) {} \
00152 catch(std::bad_alloc& ex) {}
00153
00154 #define MICATCHRETHROW \
00155 catch(MIEXCEPTION& ex) { \
00156 ex.AddSourceLine(RCSID, __LINE__); \
00157 throw; \
00158 } \
00159 catch(std::bad_alloc& ex) { \
00160 throw MIEXCEPTION(EOutOfMemoryB, __LINE__, RCSID); \
00161 }
00162
00163 #else
00164
00165 #define MITRY
00166 #define MICATCH
00167
00168 #define MICATCHRETURN
00169 #define MICATCHSETERR
00170 #define MICATCHGOTO goto Error;
00171 #define MICATCHDISPLAY(_w_)
00172 #define MICATCHDISPLAYRETURN(_w_) return;
00173 #define MICATCHIGNORE
00174 #define MICATCHRETHROW
00175
00176 #endif
00177
00178 #endif