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
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075 #ifndef Foundation_Exception_INCLUDED
00076 #define Foundation_Exception_INCLUDED
00077
00078
00079 #include "VMS/Foundation.h"
00080 #include <stdexcept>
00081
00082
00083 namespace Poco {
00084
00085
00086 class Foundation_API Exception: public std::exception
00089 {
00090 public:
00091 Exception(const std::string& msg, int code = 0);
00093
00094 Exception(const std::string& msg, const std::string& arg, int code = 0);
00096
00097 Exception(const std::string& msg, const Exception& nested, int code = 0);
00100
00101 Exception(const Exception& exc);
00103
00104 ~Exception() throw();
00106
00107 Exception& operator = (const Exception& exc);
00109
00110 virtual const char* name() const throw();
00112
00113 virtual const char* className() const throw();
00115
00116 virtual const char* what() const throw();
00120
00121 const Exception* nested() const;
00124
00125 const std::string& message() const;
00127
00128 int code() const;
00130
00131 std::string displayText() const;
00134
00135 virtual Exception* clone() const;
00140
00141 virtual void rethrow() const;
00147
00148 protected:
00149 Exception(int code = 0);
00151
00152 private:
00153 std::string _msg;
00154 Exception* _pNested;
00155 int _code;
00156 };
00157
00158
00159
00160
00161
00162 inline const Exception* Exception::nested() const
00163 {
00164 return _pNested;
00165 }
00166
00167
00168 inline const std::string& Exception::message() const
00169 {
00170 return _msg;
00171 }
00172
00173
00174 inline int Exception::code() const
00175 {
00176 return _code;
00177 }
00178
00179
00180
00181
00182
00183
00184
00185
00186 #define POCO_DECLARE_EXCEPTION(API, CLS, BASE) \
00187 class API CLS: public BASE \
00188 { \
00189 public: \
00190 CLS(int code = 0); \
00191 CLS(const std::string& msg, int code = 0); \
00192 CLS(const std::string& msg, const std::string& arg, int code = 0); \
00193 CLS(const std::string& msg, const Poco::Exception& exc, int code = 0); \
00194 CLS(const CLS& exc); \
00195 ~CLS() throw(); \
00196 CLS& operator = (const CLS& exc); \
00197 const char* name() const throw(); \
00198 const char* className() const throw(); \
00199 Poco::Exception* clone() const; \
00200 void rethrow() const; \
00201 };
00202
00203
00204 #define POCO_IMPLEMENT_EXCEPTION(CLS, BASE, NAME) \
00205 CLS::CLS(int code): BASE(code) \
00206 { \
00207 } \
00208 CLS::CLS(const std::string& msg, int code): BASE(msg, code) \
00209 { \
00210 } \
00211 CLS::CLS(const std::string& msg, const std::string& arg, int code): BASE(msg, arg, code) \
00212 { \
00213 } \
00214 CLS::CLS(const std::string& msg, const Poco::Exception& exc, int code): BASE(msg, exc, code) \
00215 { \
00216 } \
00217 CLS::CLS(const CLS& exc): BASE(exc) \
00218 { \
00219 } \
00220 CLS::~CLS() throw() \
00221 { \
00222 } \
00223 CLS& CLS::operator = (const CLS& exc) \
00224 { \
00225 BASE::operator = (exc); \
00226 return *this; \
00227 } \
00228 const char* CLS::name() const throw() \
00229 { \
00230 return NAME; \
00231 } \
00232 const char* CLS::className() const throw() \
00233 { \
00234 return typeid(*this).name(); \
00235 } \
00236 Poco::Exception* CLS::clone() const \
00237 { \
00238 return new CLS(*this); \
00239 } \
00240 void CLS::rethrow() const \
00241 { \
00242 throw *this; \
00243 }
00244
00245
00246
00247
00248
00249 POCO_DECLARE_EXCEPTION(Foundation_API, LogicException, Exception)
00250 POCO_DECLARE_EXCEPTION(Foundation_API, AssertionViolationException, LogicException)
00251 POCO_DECLARE_EXCEPTION(Foundation_API, NullPointerException, LogicException)
00252 POCO_DECLARE_EXCEPTION(Foundation_API, BugcheckException, LogicException)
00253 POCO_DECLARE_EXCEPTION(Foundation_API, InvalidArgumentException, LogicException)
00254 POCO_DECLARE_EXCEPTION(Foundation_API, NotImplementedException, LogicException)
00255 POCO_DECLARE_EXCEPTION(Foundation_API, RangeException, LogicException)
00256 POCO_DECLARE_EXCEPTION(Foundation_API, IllegalStateException, LogicException)
00257 POCO_DECLARE_EXCEPTION(Foundation_API, InvalidAccessException, LogicException)
00258 POCO_DECLARE_EXCEPTION(Foundation_API, SignalException, LogicException)
00259 POCO_DECLARE_EXCEPTION(Foundation_API, UnhandledException, LogicException)
00260
00261 POCO_DECLARE_EXCEPTION(Foundation_API, RuntimeException, Exception)
00262 POCO_DECLARE_EXCEPTION(Foundation_API, NotFoundException, RuntimeException)
00263 POCO_DECLARE_EXCEPTION(Foundation_API, ExistsException, RuntimeException)
00264 POCO_DECLARE_EXCEPTION(Foundation_API, TimeoutException, RuntimeException)
00265 POCO_DECLARE_EXCEPTION(Foundation_API, SystemException, RuntimeException)
00266 POCO_DECLARE_EXCEPTION(Foundation_API, RegularExpressionException, RuntimeException)
00267 POCO_DECLARE_EXCEPTION(Foundation_API, LibraryLoadException, RuntimeException)
00268 POCO_DECLARE_EXCEPTION(Foundation_API, LibraryAlreadyLoadedException, RuntimeException)
00269 POCO_DECLARE_EXCEPTION(Foundation_API, NoThreadAvailableException, RuntimeException)
00270 POCO_DECLARE_EXCEPTION(Foundation_API, PropertyNotSupportedException, RuntimeException)
00271 POCO_DECLARE_EXCEPTION(Foundation_API, PoolOverflowException, RuntimeException)
00272 POCO_DECLARE_EXCEPTION(Foundation_API, NoPermissionException, RuntimeException)
00273 POCO_DECLARE_EXCEPTION(Foundation_API, OutOfMemoryException, RuntimeException)
00274 POCO_DECLARE_EXCEPTION(Foundation_API, DataException, RuntimeException)
00275
00276 POCO_DECLARE_EXCEPTION(Foundation_API, DataFormatException, DataException)
00277 POCO_DECLARE_EXCEPTION(Foundation_API, SyntaxException, DataException)
00278 POCO_DECLARE_EXCEPTION(Foundation_API, CircularReferenceException, DataException)
00279 POCO_DECLARE_EXCEPTION(Foundation_API, PathSyntaxException, SyntaxException)
00280 POCO_DECLARE_EXCEPTION(Foundation_API, IOException, RuntimeException)
00281 POCO_DECLARE_EXCEPTION(Foundation_API, FileException, IOException)
00282 POCO_DECLARE_EXCEPTION(Foundation_API, FileExistsException, FileException)
00283 POCO_DECLARE_EXCEPTION(Foundation_API, FileNotFoundException, FileException)
00284 POCO_DECLARE_EXCEPTION(Foundation_API, PathNotFoundException, FileException)
00285 POCO_DECLARE_EXCEPTION(Foundation_API, FileReadOnlyException, FileException)
00286 POCO_DECLARE_EXCEPTION(Foundation_API, FileAccessDeniedException, FileException)
00287 POCO_DECLARE_EXCEPTION(Foundation_API, CreateFileException, FileException)
00288 POCO_DECLARE_EXCEPTION(Foundation_API, OpenFileException, FileException)
00289 POCO_DECLARE_EXCEPTION(Foundation_API, WriteFileException, FileException)
00290 POCO_DECLARE_EXCEPTION(Foundation_API, ReadFileException, FileException)
00291 POCO_DECLARE_EXCEPTION(Foundation_API, UnknownURISchemeException, RuntimeException)
00292
00293 POCO_DECLARE_EXCEPTION(Foundation_API, ApplicationException, Exception)
00294 POCO_DECLARE_EXCEPTION(Foundation_API, BadCastException, RuntimeException)
00295
00296
00297 }
00298
00299
00300 #endif // Foundation_Exception_INCLUDED