00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include "KeosException.h"
00023 #include "KeosString.h"
00024
00025 namespace Keos
00026 {
00027
00028
00029
00030
00031 CException* CException::ms_pLast = NULL;
00032
00033
00034 CException::CException(const String& strMessage) :
00035 m_strMessage(strMessage)
00036 {
00037 ms_pLast = this;
00038 m_strShortMessage = "EXCEPTION undefined";
00039 }
00040
00041
00042 CException::~CException()
00043 {}
00044
00045
00046 const char* CException::what() const
00047 {
00048 return m_strMessage.c_str();
00049 }
00050
00051
00052 const char* CException::what_short() const
00053 {
00054 return m_strShortMessage.c_str();
00055 }
00056
00057
00058 CException* CException::GetLastException(void) throw()
00059 {
00060 return ms_pLast;
00061 }
00062
00063
00064 void CException::SetFileLine(String strFile, int nLine)
00065 {
00066 std::ostringstream oss;
00067 oss << m_strMessage << std::endl << "File: '" << strFile << "' Line: "
00068 << CStringConverter::ToString(nLine);
00069 m_strMessage = oss.str();
00070
00071 std::ostringstream oss2;
00072 oss2 << m_strShortMessage << " (" << strFile << ", L"
00073 << CStringConverter::ToString(nLine) << ")";
00074 m_strShortMessage = oss2.str();
00075 }
00076
00077
00078
00079
00080
00081
00082
00083 CAssertException::CAssertException(const String& strFile, int nLine, const String& strMessage)
00084 {
00085
00086 std::ostringstream oss;
00087 oss << strMessage << std::endl;
00088 oss << strFile << " (" << nLine << ")";
00089
00090 m_strMessage = oss.str();
00091 }
00092
00093
00094
00095
00096
00097
00098
00099 CBadDelete::CBadDelete(const void* pPtr, const String& strFile, int nLine, bool bNewArray)
00100 {
00101
00102 std::ostringstream oss;
00103 oss << "EXCEPTION CBadDelete --> "
00104 << (bNewArray ? "new[] / delete" : "new / delete[]")
00105 << " detectee" << std::endl
00106 << "Address : 0x" << pPtr << std::endl
00107 << "Source file : " << strFile << " (" << nLine << ")";
00108
00109 m_strMessage = oss.str();
00110
00111 std::ostringstream oss2;
00112 oss2 << "EXCEPTION CBadDelete --> "
00113 << (bNewArray ? "new[] / delete" : "new / delete[]")
00114 << " detectee";
00115
00116 m_strShortMessage = oss2.str();
00117 }
00118
00119
00120
00121
00122
00123
00124
00125 CLoadingFailed::CLoadingFailed(const String& strFile, const String& strMessage, const String& strSource)
00126 {
00127
00128 std::ostringstream oss;
00129 oss << "EXCEPTION CLoadingFailed in " << strSource << std::endl
00130 << "Error in the load of '" << strFile << "'" << std::endl << strMessage;
00131
00132 m_strMessage = oss.str();
00133
00134 std::ostringstream oss2;
00135 oss2 << "EXCEPTION CLoadingFailed in " << strSource << " --> "
00136 << "Error in the load of '" << strFile << "'";
00137
00138 m_strShortMessage = oss2.str();
00139 }
00140
00141
00142
00143
00144
00145
00146
00147 CDynLibError::CDynLibError(const String& strFile, const String& strMessage, const String& strSource)
00148 {
00149
00150 std::ostringstream oss;
00151 oss << "EXCEPTION CDynLibError in " << strSource << std::endl
00152 << "Error in the library '" << strFile << "'" << std::endl << strMessage;
00153
00154 m_strMessage = oss.str();
00155
00156 std::ostringstream oss2;
00157 oss2 << "EXCEPTION CDynLibError in " << strSource << " --> "
00158 << "Error in the library '" << strFile << "'";
00159
00160 m_strShortMessage = oss2.str();
00161 }
00162
00163
00164
00165
00166
00167
00168
00169 COutOfMemory::COutOfMemory(const String& strMessage, const String& strSource)
00170 {
00171
00172 std::ostringstream oss;
00173 oss << "EXCEPTION COutOfMemory in " << strSource << std::endl << strMessage;
00174
00175 m_strMessage = oss.str();
00176
00177 std::ostringstream oss2;
00178 oss2 << "EXCEPTION COutOfMemory in " << strSource;
00179
00180 m_strShortMessage = oss2.str();
00181 }
00182
00183
00184
00185
00186
00187
00188 CUnsupported::CUnsupported(const String& strFeature, const String& strSource)
00189 {
00190
00191 std::ostringstream oss;
00192 oss << "EXCEPTION CUnsupported in " << strSource << std::endl
00193 << "Unsupported feature : " << strFeature;
00194
00195 m_strMessage = oss.str();
00196
00197 std::ostringstream oss2;
00198 oss2 << "EXCEPTION CUnsupported in " << strSource << " --> "
00199 << "Unsupported feature : " << strFeature;
00200
00201 m_strShortMessage = oss2.str();
00202 }
00203
00204
00205
00206
00207
00208
00209 CBadConversion::CBadConversion(const String& strError, const String& strSource)
00210 {
00211
00212 std::ostringstream oss;
00213 oss << "EXCEPTION CBadConversion in " << strSource << std::endl
00214 << "Conversion error : " << strError;
00215
00216 m_strMessage = oss.str();
00217
00218 std::ostringstream oss2;
00219 oss2 << "EXCEPTION CBadConversion in " << strSource << " --> "
00220 << "Conversion error : " << strError;
00221
00222 m_strShortMessage = oss2.str();
00223 }
00224 }