00001 /* 00002 * This file is part of the Standard Portable Library (SPL). 00003 * 00004 * SPL is free software: you can redistribute it and/or modify 00005 * it under the terms of the GNU General Public License as published by 00006 * the Free Software Foundation, either version 3 of the License, or 00007 * (at your option) any later version. 00008 * 00009 * SPL is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 * GNU General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU General Public License 00015 * along with SPL. If not, see <http://www.gnu.org/licenses/>. 00016 */ 00017 #ifndef _exception_h 00018 #define _exception_h 00019 00020 #include <spl/Debug.h> 00021 00031 class Exception 00032 { 00033 protected: 00034 char m_msg[512]; 00035 00036 public: 00037 Exception( ); 00038 Exception( const char *msg ); 00039 00040 virtual ~Exception(); 00041 00042 inline const char *Message() const 00043 { 00044 return m_msg; 00045 } 00046 }; 00047 00048 class OutOfMemoryException : public Exception 00049 { 00050 public: 00051 OutOfMemoryException(); 00052 }; 00053 00054 class SqlException : public Exception 00055 { 00056 public: 00057 SqlException(const char *msg); 00058 }; 00059 00060 class IndexOutOfBoundsException : public Exception 00061 { 00062 public: 00063 IndexOutOfBoundsException(); 00064 inline IndexOutOfBoundsException(const char *msg) 00065 : Exception(msg) 00066 { 00067 } 00068 }; 00069 00070 class InvalidArgumentException : public Exception 00071 { 00072 public: 00073 InvalidArgumentException(const char *msg); 00074 }; 00075 00076 class IOException : public Exception 00077 { 00078 public: 00079 IOException(const char *msg); 00080 }; 00081 00082 class AssertionFailedException : public Exception 00083 { 00084 public: 00085 AssertionFailedException(const char *msg); 00086 }; 00087 00088 class NotImplementedException : public Exception 00089 { 00090 public: 00091 NotImplementedException(const char *msg); 00092 NotImplementedException(); 00093 }; 00094 00095 class IErrorListener 00096 { 00097 public: 00098 virtual void OnError(const char *msg) = 0; 00099 }; 00100 00101 class SocketException : public Exception 00102 { 00103 public: 00104 SocketException( const char *msg ); 00105 }; 00106 00107 class ThreadStartException : public Exception 00108 { 00109 public: 00110 ThreadStartException(); 00111 }; 00112 00113 class FileNotFoundException : public Exception 00114 { 00115 public: 00116 FileNotFoundException(const char *filename); 00117 }; 00118 00119 class PacketUnderflowException : public Exception 00120 { 00121 public: 00122 PacketUnderflowException(); 00123 }; 00124 00125 class PacketReadTypeMismatchException : public Exception 00126 { 00127 public: 00128 PacketReadTypeMismatchException(const char *msg); 00129 }; 00130 00131 class PacketNotReadyException : public Exception 00132 { 00133 public: 00134 PacketNotReadyException(const char *msg); 00135 }; 00136 00137 class InvalidTypeConversionException : public Exception 00138 { 00139 public: 00140 InvalidTypeConversionException(); 00141 InvalidTypeConversionException(const char *msg); 00142 }; 00143 00144 class StateException : public Exception 00145 { 00146 public: 00147 StateException(const char *msg); 00148 }; 00149 00150 class SecurityException : public Exception 00151 { 00152 public: 00153 SecurityException(const char *msg); 00154 }; 00155 00156 class ConfigurationException : public Exception 00157 { 00158 public: 00159 ConfigurationException(const char *msg); 00160 }; 00161 00162 class XmlException : public Exception 00163 { 00164 protected: 00165 int m_row; 00166 int m_col; 00167 00168 public: 00169 XmlException(const char *msg, int row, int col); 00170 00171 inline int Row() const { return m_row; } 00172 inline int Col() const { return m_col; } 00173 }; 00174 00175 class ProtocolException : public Exception 00176 { 00177 public: 00178 inline ProtocolException(const char *msg) 00179 : Exception(msg) 00180 { 00181 } 00182 }; 00183 00184 class SyntaxException : public Exception 00185 { 00186 public: 00187 inline SyntaxException(const char *msg) 00188 : Exception(msg) 00189 { 00190 } 00191 }; 00192 00195 #endif