00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #include "SO3Exception.h"
00029 #include "OgreLogManager.h"
00030
00031 namespace SO3
00032 {
00033
00034 SException::SException(const std::string& desc, const std::string& src, bool exceptToLogFile) : line(0),
00035 description(desc),
00036 source(src),
00037 toLogFile(exceptToLogFile)
00038 {
00039 if(toLogFile)
00040 Ogre::LogManager::getSingleton().logMessage(GetFullDescription(), Ogre::LML_CRITICAL);
00041 }
00042
00043 SException::SException(const std::string& desc, const std::string& src, const char* typ, const char* fil, long lin, bool exceptToLogFile) : line(lin),
00044 typeName(typ),
00045 description(desc),
00046 source(src),
00047 file(fil),
00048 toLogFile(exceptToLogFile)
00049 {
00050 if(toLogFile)
00051 Ogre::LogManager::getSingleton().logMessage(GetFullDescription(), Ogre::LML_CRITICAL);
00052 }
00053
00054 SException::SException(const SException& exception) : line(exception.line),
00055 typeName(exception.typeName),
00056 description(exception.description),
00057 source(exception.source),
00058 file(exception.file),
00059 toLogFile(exception.toLogFile)
00060 {
00061 }
00062
00063 SException::~SException() throw()
00064 {
00065 }
00066
00067 void SException::operator =(const SException& exception)
00068 {
00069 description = exception.description;
00070 source = exception.source;
00071 file = exception.file;
00072 line = exception.line;
00073 typeName = exception.typeName;
00074 toLogFile = exception.toLogFile;
00075 }
00076
00077 const std::string& SException::GetFullDescription() const
00078 {
00079 if (fullDesc.empty())
00080 {
00081 std::ostringstream desc;
00082 desc << "SO3 EXCEPTION(" << typeName << "): " << description << " in " << source;
00083
00084 if(line > 0)
00085 {
00086 desc << " at " << file << " (line " << line << ")";
00087 }
00088
00089 fullDesc = desc.str();
00090 }
00091 return fullDesc;
00092 }
00093
00094 const std::string& SException::GetSource() const
00095 {
00096 return source;
00097 }
00098
00099 const std::string& SException::GetFile() const
00100 {
00101 return file;
00102 }
00103
00104 long SException::GetLine() const
00105 {
00106 return line;
00107 }
00108
00109 const std::string& SException::GetDescription() const
00110 {
00111 return description;
00112 }
00113
00114 const char* SException::what() const throw()
00115 {
00116 return GetFullDescription().c_str();
00117 }
00118
00119 SExceptionUnimplemented::SExceptionUnimplemented(const std::string& exceptDescription, const std::string& exceptSource, const char* exceptFile, long exceptLine, bool exceptToLogFile) : SException(exceptDescription, exceptSource, "SExceptionUnimplemented", exceptFile, exceptLine, exceptToLogFile)
00120 {
00121 }
00122
00123 SExceptionFileNotFound::SExceptionFileNotFound(const std::string& exceptDescription, const std::string& exceptSource, const char* exceptFile, long exceptLine, bool exceptToLogFile) : SException(exceptDescription, exceptSource, "SExceptionFileNotFound", exceptFile, exceptLine, exceptToLogFile)
00124 {
00125 }
00126
00127 SExceptionIO::SExceptionIO(const std::string& exceptDescription, const std::string& exceptSource, const char* exceptFile, long exceptLine, bool exceptToLogFile) : SException(exceptDescription, exceptSource, "SExceptionIO", exceptFile, exceptLine, exceptToLogFile)
00128 {
00129 }
00130
00131 SExceptionItemIdentity::SExceptionItemIdentity(const std::string& exceptDescription, const std::string& exceptSource, const char* exceptFile, long exceptLine, bool exceptToLogFile) : SException(exceptDescription, exceptSource, "SExceptionItemIdentity", exceptFile, exceptLine, exceptToLogFile)
00132 {
00133 }
00134
00135 SExceptionItemNotFound::SExceptionItemNotFound(const std::string& exceptDescription, const std::string& exceptSource, const char* exceptFile, long exceptLine, bool exceptToLogFile) : SException(exceptDescription, exceptSource, "SExceptionItemNotFound", exceptFile, exceptLine, exceptToLogFile)
00136 {
00137 }
00138
00139 SExceptionInternalError::SExceptionInternalError(const std::string& exceptDescription, const std::string& exceptSource, const char* exceptFile, long exceptLine, bool exceptToLogFile) : SException(exceptDescription, exceptSource, "SExceptionInternalError", exceptFile, exceptLine, exceptToLogFile)
00140 {
00141 }
00142
00143 SExceptionExternalAPIError::SExceptionExternalAPIError(const std::string& exceptDescription, const std::string& exceptSource, const char* exceptFile, long exceptLine, bool exceptToLogFile) : SException(exceptDescription, exceptSource, "SExceptionExternalAPIError", exceptFile, exceptLine, exceptToLogFile)
00144 {
00145 }
00146
00147 SExceptionInvalidParameters::SExceptionInvalidParameters(const std::string& exceptDescription, const std::string& exceptSource, const char* exceptFile, long exceptLine, bool exceptToLogFile) : SException(exceptDescription, exceptSource, "SExceptionInvalidParameters", exceptFile, exceptLine, exceptToLogFile)
00148 {
00149 }
00150
00151 SExceptionNullReference::SExceptionNullReference(const std::string& exceptDescription, const std::string& exceptSource, const char* exceptFile, long exceptLine, bool exceptToLogFile) : SException(exceptDescription, exceptSource, "SExceptionNullReference", exceptFile, exceptLine, exceptToLogFile)
00152 {
00153 }
00154
00155 SExceptionBadCast::SExceptionBadCast(const std::string& exceptDescription, const std::string& exceptSource, const char* exceptFile, long exceptLine, bool exceptToLogFile) : SException(exceptDescription, exceptSource, "SExceptionBadCast", exceptFile, exceptLine, exceptToLogFile)
00156 {
00157 }
00158
00159 SExceptionWriteData::SExceptionWriteData(const std::string& exceptDescription, const std::string& exceptSource, const char* exceptFile, long exceptLine, bool exceptToLogFile) : SException(exceptDescription, exceptSource, "SExceptionWriteData", exceptFile, exceptLine, exceptToLogFile)
00160 {
00161 }
00162
00163 SExceptionWriteOnly::SExceptionWriteOnly(const std::string& exceptDescription, const std::string& exceptSource, const char* exceptFile, long exceptLine, bool exceptToLogFile) : SException(exceptDescription, exceptSource, "SExceptionWriteOnly", exceptFile, exceptLine, exceptToLogFile)
00164 {
00165 }
00166
00167 SExceptionReadData::SExceptionReadData(const std::string& exceptDescription, const std::string& exceptSource, const char* exceptFile, long exceptLine, bool exceptToLogFile) : SException(exceptDescription, exceptSource, "SExceptionReadData", exceptFile, exceptLine, exceptToLogFile)
00168 {
00169 }
00170
00171 SExceptionReadOnly::SExceptionReadOnly(const std::string& exceptDescription, const std::string& exceptSource, const char* exceptFile, long exceptLine, bool exceptToLogFile) : SException(exceptDescription, exceptSource, "SExceptionReadOnly", exceptFile, exceptLine, exceptToLogFile)
00172 {
00173 }
00174
00175 SExceptionOutOfBound::SExceptionOutOfBound(const std::string& exceptDescription, const std::string& exceptSource, const char* exceptFile, long exceptLine, bool exceptToLogFile) : SException(exceptDescription, exceptSource, "SExceptionOutOfBound", exceptFile, exceptLine, exceptToLogFile)
00176 {
00177 }
00178
00179 }