00001 00016 #ifndef SICK_EXCEPTION 00017 #define SICK_EXCEPTION 00018 00019 /* Definition dependencies */ 00020 #include <string> 00021 #include <exception> 00022 00023 /* Associate the namespace */ 00024 namespace SickToolbox { 00025 00030 class SickException : std::exception { 00031 00032 public: 00033 00038 SickException( const std::string general_str ) { 00039 _detailed_msg = general_str; 00040 } 00041 00047 SickException( const std::string general_str, const std::string detailed_str ) { 00048 _detailed_msg = general_str + " " + detailed_str; 00049 } 00050 00054 virtual const char* what( ) const throw() { 00055 return _detailed_msg.c_str(); 00056 } 00057 00061 ~SickException() throw() {} 00062 00063 private: 00064 00066 std::string _detailed_msg; 00067 00068 }; 00069 00074 class SickTimeoutException : public SickException { 00075 00076 public: 00077 00081 SickTimeoutException() : 00082 SickException("A Timeout Occurred!") { } 00083 00088 SickTimeoutException( const std::string detailed_str ) : 00089 SickException("A Timeout Occurred -",detailed_str) { } 00090 00094 ~SickTimeoutException() throw() { } 00095 00096 }; 00097 00103 class SickIOException : public SickException { 00104 00105 public: 00106 00110 SickIOException() : 00111 SickException("ERROR: I/O exception!") { } 00112 00117 SickIOException( const std::string detailed_str ) : 00118 SickException("ERROR: I/O exception -",detailed_str) { } 00119 00123 ~SickIOException() throw() { } 00124 00125 }; 00126 00132 class SickBadChecksumException : public SickException { 00133 00134 public: 00135 00139 SickBadChecksumException() : 00140 SickException("ERROR: Bad Checksum!") { } 00141 00146 SickBadChecksumException( const std::string detailed_str ) : 00147 SickException("ERROR: Bad Checksum -",detailed_str) { } 00148 00152 ~SickBadChecksumException() throw() { } 00153 00154 }; 00155 00161 class SickThreadException : public SickException { 00162 00163 public: 00164 00168 SickThreadException() : 00169 SickException("ERROR: Sick thread exception!") { } 00170 00175 SickThreadException( const std::string detailed_str ) : 00176 SickException("ERROR: Sick thread exception -",detailed_str) { } 00177 00181 ~SickThreadException() throw() { } 00182 00183 }; 00184 00190 class SickConfigException : public SickException { 00191 00192 public: 00193 00197 SickConfigException() : 00198 SickException("ERROR: Config exception!") { } 00199 00204 SickConfigException( const std::string detailed_str ) : 00205 SickException("ERROR: Config exception -",detailed_str) { } 00206 00210 ~SickConfigException() throw() { } 00211 00212 }; 00213 00219 class SickErrorException : public SickException { 00220 00221 public: 00222 00226 SickErrorException() : 00227 SickException("ERROR: Sick returned error code!") { }; 00228 00233 SickErrorException( const std::string detailed_str ) : 00234 SickException("ERROR: Sick error -", detailed_str) { } 00235 00239 ~SickErrorException() throw() { } 00240 00241 }; 00242 } /* namespace SickToolbox */ 00243 00244 #endif /* SICK_EXCEPTION */