00001 /** 00002 * \file mi32/errhandler.h 00003 * \brief Error reporting and handling functions 00004 * 00005 * \if NODOC 00006 * $Id: errhandler.h_v 1.3 2005/06/24 19:10:08 mju Exp $ 00007 * 00008 * $Log: errhandler.h_v $ 00009 * Revision 1.3 2005/06/24 19:10:08 mju 00010 * Fix comment at end. 00011 * 00012 * Revision 1.2 2005/06/22 15:38:15 mju 00013 * Adjust comment. 00014 * 00015 * Revision 1.1 2005/06/22 15:26:11 mju 00016 * Initial revision 00017 * 00018 * \endif 00019 **/ 00020 00021 #ifndef INC_MI32_ERRHANDLER_H 00022 #define INC_MI32_ERRHANDLER_H 00023 00024 #ifndef INC_MI32_STDDEFNS_H 00025 #include <mi32/stddefns.h> 00026 #endif 00027 00028 #ifdef MISYSTEMDLL 00029 #define LIBEXPORT MI_DLLEXPORT 00030 #else 00031 #define LIBEXPORT MI_DLLIMPORT 00032 #endif 00033 00034 00035 #ifdef __cplusplus 00036 class MISTRING; 00037 #endif 00038 00039 //!\addtogroup ErrorPosn Error Reporting Functions 00040 //!@{ 00041 00042 #ifndef GENERATING_DOXYGEN_OUTPUT 00043 #if defined(__cplusplus) 00044 extern "C" { 00045 #endif 00046 #endif 00047 00048 //! Clear the last reported error and the error stack. 00049 LIBEXPORT void ClearLastErr (void); 00050 00051 //! Get the details string set by SetErrDetails(). 00052 //! Do not free the returned string. 00053 LIBEXPORT const MIUNICODE* GetErrDetails (); 00054 00055 #if defined(__cplusplus) 00056 00057 //! Get MISTRING reference to current error message. 00058 //! This allows subsequent use of the << operator on the string to substitute 00059 //! or append additional error values for %-format or $-position codes. 00060 LIBEXPORT MISTRING& GetErrString ( 00061 ); 00062 00063 //! Get the last error message (Unicode). 00064 //! Do not free the returned string. 00065 LIBEXPORT const MIUNICODE* GetErrStrUC ( 00066 ERRVALUE errcode, //!< Error code to retrieve string for 00067 int *errlevel = 0 //!< Error level returned (NULL if don't care) 00068 ); 00069 00070 00071 //! Get the first line of the last error message (Unicode). 00072 //! Do not free the returned string. 00073 LIBEXPORT const MIUNICODE* GetErrStrLine1UC ( 00074 ERRVALUE errcode, //!< Error code to retrieve string for 00075 int *errlevel = 0 //!< Error level returned (NULL if don't care) 00076 ); 00077 00078 //! Determine if error position recording is disabled. 00079 //! @return true if disabled, false if not. 00080 LIBEXPORT bool IsErrPosnDisabled (); 00081 00082 #else 00083 #ifndef GENERATING_DOXYGEN_OUTPUT 00084 //! Version of above without default parameter for 3rd party libs 00085 //! that don't compile with C++ but that we still have to patch 00086 //! to use Mio 00087 00088 LIBEXPORT const MIUNICODE* GetErrStrUC ( 00089 ERRVALUE errcode, //!< Error code to retrieve string for 00090 int *errlevel //!< Error level returned (NULL if don't care) 00091 ); 00092 00093 LIBEXPORT const MIUNICODE* GetErrStrLine1UC ( 00094 ERRVALUE errcode, //!< Error code to retrieve string for 00095 int *errlevel //!< Error level returned (NULL if don't care) 00096 ); 00097 00098 #endif // GENERATING_DOXYGEN_OUTPUT 00099 #endif 00100 00101 //! Get last error code. 00102 LIBEXPORT ERRVALUE GetLastErrCode (); 00103 00104 //! Set the details string for an error. 00105 //! This can be used to report any extra details about an error. 00106 //! If set, the standard error dialog will have a "detial..." button 00107 //! which will let the user see the details. 00108 LIBEXPORT void SetErrDetails ( 00109 const MIUNICODE* 00110 ); 00111 00112 #ifndef GENERATING_DOXYGEN_OUTPUT 00113 LIBEXPORT int _SetErrPosn (int, const char*, int); 00114 LIBEXPORT int _SetErrPosnC (int, const char*, int); 00115 #endif // GENERATING_DOXYGEN_OUTPUT 00116 00117 //! Record an error code and it's position. 00118 //! 00119 //! Note, this is really a macro which calls an internal function 00120 //! and also passes it RCSID and __LINE__ 00121 //! For this to work, the following line must exist near the top 00122 //! of the module (just below the main comment block) 00123 //! @code 00124 //! #define RCSID "$Id: errhandler.h_v 1.3 2005/06/24 19:10:08 mju Exp $" 00125 //! @endcode 00126 //! 00127 //! Note: The example above shows what the RCSID for this include file looks 00128 //! like. If you're using RCS, it will fill in everything between the <tt>Id:</tt> and the <tt>$</tt>. 00129 //! The actual source module will be specific to the file in which RCSID is defined, and 00130 //! will be extracted from the RCSID string along with the revision number and date for 00131 //! display in error traces. 00132 #define SetErrPosn(e) _SetErrPosn(e,RCSID,__LINE__) 00133 00134 //! Clear current error stack and set error position. 00135 //! 00136 //! Same as SetErrPosn(), but clears the error stack first. 00137 //! 00138 //! @see SetErrPosn() 00139 #define SetErrPosnC(e) _SetErrPosnC(e,RCSID,__LINE__) 00140 00141 00142 //! Set the current error position and goto Error label. 00143 //! 00144 //! Note, This is really a #define macro. 00145 //! 00146 //! It does the same thing as SetErrPosn(), then does a 00147 //! <tt>goto Error;</tt> 00148 #define SetErrPosnGoto(e) { err=SetErrPosn(e); goto Error; } 00149 00150 //! Clear the error stack, set the current error position and goto Error label. 00151 //! 00152 //! Note, This is really a #define macro. 00153 //! It does the same thing as SetErrPosnC(), then does a 00154 //! <tt>goto Error;</tt> 00155 #define SetErrPosnGotoC(e) { err=SetErrPosnC(e); goto Error; } 00156 00157 00158 //! Disable error position reporting. 00159 //! 00160 //! This is important when cleaning up after an error. It often happens that 00161 //! if you get an error, you need to cleanup (close files, etc) before returning. 00162 //! If something in your cleanup code also causes an error, it will wipe out 00163 //! the error trace that you're trying to report. Therefore, always bracket 00164 //! cleanup code with SetErrPosnDiaable()/SetErrPosnEnable(). 00165 LIBEXPORT void SetErrPosnDisable (void); 00166 00167 //! Reenable error position reporting. 00168 //! 00169 //! @see SetErrPosnDisable() 00170 LIBEXPORT void SetErrPosnEnable (void); 00171 00172 #if defined(__cplusplus) 00173 } 00174 #endif 00175 00176 //!@} 00177 00178 00179 #if defined(__cplusplus) 00180 //! Sentry class to disable and enable error positioning using this class and scoping 00181 class ERRORPOSNDISABLE { 00182 public: 00183 ERRORPOSNDISABLE ( 00184 ) { SetErrPosnDisable(); } 00185 00186 ~ERRORPOSNDISABLE ( 00187 ) { SetErrPosnEnable(); } 00188 }; 00189 00190 #endif 00191 00192 #undef LIBEXPORT 00193 00194 #endif // INC_MI32_ERRHANDLER_H
1.5.2