00001 #ifndef EXCEPTIONS_H_ 00002 #define EXCEPTIONS_H_ 00003 00004 #include <string> 00005 using namespace std; 00006 00007 namespace dtn 00008 { 00009 namespace data 00010 { 00014 class Bundle; 00015 } 00016 00017 namespace exceptions 00018 { 00022 class Exception 00023 { 00024 public: 00028 Exception() 00029 {}; 00030 00035 Exception(string what) 00036 { 00037 m_what = what; 00038 }; 00039 00044 string what() 00045 { 00046 return m_what; 00047 }; 00048 00049 private: 00050 string m_what; 00051 }; 00052 00056 class InvalidFieldException : public Exception 00057 { 00058 public: 00059 InvalidFieldException() : Exception("The given field is invalid.") 00060 { 00061 }; 00062 00063 InvalidFieldException(string what) : Exception(what) 00064 { 00065 }; 00066 }; 00067 00071 class FieldDoesNotExist : public Exception 00072 { 00073 public: 00074 FieldDoesNotExist() : Exception("This field don't exists.") 00075 { 00076 }; 00077 00078 FieldDoesNotExist(string what) : Exception(what) 00079 { 00080 }; 00081 }; 00082 00086 class InvalidBundleData : public Exception 00087 { 00088 public: 00089 InvalidBundleData() : Exception("The bundle contains invalid data.") 00090 { 00091 }; 00092 00093 InvalidBundleData(string what) : Exception(what) 00094 { 00095 }; 00096 }; 00097 00101 class SDNVDecodeFailed : public Exception 00102 { 00103 public: 00104 SDNVDecodeFailed() : Exception("Decoding of a SDNV failed.") 00105 { 00106 }; 00107 00108 SDNVDecodeFailed(string what) : Exception(what) 00109 { 00110 }; 00111 }; 00112 00116 class InvalidOptionException : public Exception 00117 { 00118 public: 00119 InvalidOptionException() : Exception("Invalid option.") 00120 { 00121 }; 00122 00123 InvalidOptionException(string what) : Exception(what) 00124 { 00125 }; 00126 }; 00127 00131 class InvalidDataException : public Exception 00132 { 00133 public: 00134 InvalidDataException() : Exception("Invalid input data.") 00135 { 00136 }; 00137 00138 InvalidDataException(string what) : Exception(what) 00139 { 00140 }; 00141 }; 00142 00146 class NoScheduleFoundException : public Exception 00147 { 00148 public: 00149 NoScheduleFoundException() : Exception("No schedule found.") 00150 { 00151 }; 00152 00153 NoScheduleFoundException(string what) : Exception(what) 00154 { 00155 }; 00156 }; 00157 00161 class NoBundleFoundException : public Exception 00162 { 00163 public: 00164 NoBundleFoundException() : Exception("No bundle available.") 00165 { 00166 }; 00167 00168 NoBundleFoundException(string what) : Exception(what) 00169 { 00170 }; 00171 }; 00172 00176 class MaxSizeTooSmallException : public Exception 00177 { 00178 public: 00179 MaxSizeTooSmallException() : Exception("Maximum size is too small.") 00180 { 00181 }; 00182 00183 MaxSizeTooSmallException(string what) : Exception(what) 00184 { 00185 }; 00186 }; 00187 00191 class FragmentationException : public Exception 00192 { 00193 public: 00194 FragmentationException() : Exception("De-/fragmentation not possible.") 00195 { 00196 }; 00197 00198 FragmentationException(string what) : Exception(what) 00199 { 00200 }; 00201 }; 00202 00206 class DoNotFragmentBitSetException : public FragmentationException 00207 { 00208 public: 00209 DoNotFragmentBitSetException() : FragmentationException("Do not fragment-bit is set. Fragmentation not possible.") 00210 { 00211 }; 00212 00213 DoNotFragmentBitSetException(string what) : FragmentationException(what) 00214 { 00215 }; 00216 }; 00217 00222 class BundleFragmentedException: public FragmentationException, InvalidBundleData 00223 { 00224 public: 00225 BundleFragmentedException(data::Bundle *fragment) : FragmentationException("Bundle data is fragmented."), InvalidBundleData("Bundle data is fragmented."), m_fragment(fragment) 00226 { 00227 }; 00228 00229 BundleFragmentedException(string what, data::Bundle *fragment) : FragmentationException(what), InvalidBundleData(what), m_fragment(fragment) 00230 { 00231 }; 00232 00233 data::Bundle *getFragment() 00234 { 00235 return m_fragment; 00236 } 00237 00238 private: 00239 data::Bundle *m_fragment; 00240 }; 00241 00245 class BundleExpiredException : public Exception 00246 { 00247 public: 00248 BundleExpiredException() : Exception("This bundle has expired.") 00249 { 00250 }; 00251 00252 BundleExpiredException(string what) : Exception(what) 00253 { 00254 }; 00255 }; 00256 00260 class NoSpaceLeftException : public Exception 00261 { 00262 public: 00263 NoSpaceLeftException() : Exception("No space left.") 00264 { 00265 }; 00266 00267 NoSpaceLeftException(string what) : Exception(what) 00268 { 00269 }; 00270 }; 00271 00275 class NoNeighbourFoundException : public Exception 00276 { 00277 public: 00278 NoNeighbourFoundException() : Exception("No neighbour was found.") 00279 { 00280 }; 00281 00282 NoNeighbourFoundException(string what) : Exception(what) 00283 { 00284 }; 00285 }; 00286 00287 class NoTimerFoundException : public Exception 00288 { 00289 public: 00290 NoTimerFoundException() : Exception("No matching timer was found.") 00291 { 00292 }; 00293 00294 NoTimerFoundException(string what) : Exception(what) 00295 { 00296 }; 00297 }; 00298 00299 class MissingObjectException : public Exception 00300 { 00301 public: 00302 MissingObjectException() : Exception("Object not available.") 00303 { 00304 }; 00305 00306 MissingObjectException(string what) : Exception(what) 00307 { 00308 }; 00309 }; 00310 } 00311 } 00312 00313 #endif /*EXCEPTIONS_H_*/
1.5.6