00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef KEOS_EXCEPTION_H
00023 #define KEOS_EXCEPTION_H
00024
00025 #include "KeosPrerequisites.h"
00026
00027 #define BADDELETE_EXCEPT(p, f, l, a) {Keos::CBadDelete except((p), (f), (l), (a)); LOG_TMP}
00028 #define LOADINGFAILED_EXCEPT(f, m, s) {Keos::CLoadingFailed except((f), (m), (s)); LOG_TMP}
00029 #define DYNLIB_EXCEPT(f, m, s) {Keos::CDynLibError except((f), (m), (s)); LOG_TMP}
00030 #define OUTOFMEMORY_EXCEPT( m, s) {Keos::COutOfMemory except((m), (s)); LOG_TMP}
00031 #define UNSUPPORTED_EXCEPT( m, s) {Keos::CUnsupported except((m), (s)); LOG_TMP}
00032 #define BADCONVERSION_EXCEPT( m, s) {Keos::CBadConversion except((m), (s)); LOG_TMP}
00033
00034 #define LOG_TMP except.SetFileLine(__FILE__, __LINE__); Keos::ILogger::Log("%s",except.what_short()); throw except;
00035
00036 namespace Keos
00037 {
00038
00042 class KEOS_EXPORT CException : public std::exception
00043 {
00044 public :
00045
00049 CException(const String& strMessage = "");
00050
00054 virtual ~CException();
00055
00059 virtual const char* what() const;
00060
00064 const char* what_short() const;
00065
00068 static CException* GetLastException(void) throw();
00069
00072 void SetFileLine(String strFile, int nLine);
00073
00074 protected :
00075
00077 String m_strMessage;
00079 String m_strShortMessage;
00081 static CException* ms_pLast;
00082 };
00083
00084
00085
00089 struct KEOS_EXPORT CAssertException : public CException
00090 {
00096 CAssertException(const String& strFile, int nLine, const String& strMessage);
00097 };
00098
00099
00100
00101 #ifdef KEOS_DEBUG_MODE
00102 # define Assert(condition) if (!(condition)) throw CAssertException(__FILE__, __LINE__, "Unsatisfied condition\n\n" #condition)
00103 #else
00104
00105 inline void DoNothing(bool)
00106 {}
00107 # define Assert(condition) DoNothing(!(condition))
00108 #endif
00109
00110
00111
00115 struct KEOS_EXPORT CBadDelete : public CException
00116 {
00123 CBadDelete(const void* pPtr, const String& strFile, int nLine, bool bNewArray);
00124 };
00125
00126
00127
00131 struct KEOS_EXPORT CLoadingFailed : public CException
00132 {
00138 CLoadingFailed(const String& strFile, const String& strMessage, const String& strSource);
00139 };
00140
00141
00145 struct KEOS_EXPORT CDynLibError : public CException
00146 {
00152 CDynLibError(const String& strFile, const String& strMessage, const String& strSource);
00153 };
00154
00155
00156
00160 struct KEOS_EXPORT COutOfMemory : public CException
00161 {
00166 COutOfMemory(const String& strMessage, const String& strSource);
00167 };
00168
00169
00173 struct KEOS_EXPORT CUnsupported : public CException
00174 {
00179 CUnsupported(const String& strFeature, const String& strSource);
00180 };
00181
00182
00186 struct KEOS_EXPORT CBadConversion : public CException
00187 {
00192 CBadConversion(const String& strError, const String& strSource);
00193 };
00194
00195 }
00196
00197 #endif // KEOS_EXCEPTION_H