Exception.h
Go to the documentation of this file.
00001 //
00002 // Exception.h
00003 //
00004 // $Id: //poco/1.3/Foundation/include/Poco/Exception.h#2 $
00005 //
00006 // Library: Foundation
00007 // Package: Core
00008 // Module:  Exception
00009 //
00010 // Definition of various Poco exception classes.
00011 //
00012 // Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
00013 // and Contributors.
00014 //
00015 // Permission is hereby granted, free of charge, to any person or organization
00016 // obtaining a copy of the software and accompanying documentation covered by
00017 // this license (the "Software") to use, reproduce, display, distribute,
00018 // execute, and transmit the Software, and to prepare derivative works of the
00019 // Software, and to permit third-parties to whom the Software is furnished to
00020 // do so, all subject to the following:
00021 // 
00022 // The copyright notices in the Software and this entire statement, including
00023 // the above license grant, this restriction and the following disclaimer,
00024 // must be included in all copies of the Software, in whole or in part, and
00025 // all derivative works of the Software, unless such copies or derivative
00026 // works are solely in the form of machine-executable object code generated by
00027 // a source language processor.
00028 // 
00029 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
00030 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00031 // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
00032 // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
00033 // FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
00034 // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
00035 // DEALINGS IN THE SOFTWARE.
00036 //
00037 
00038 
00039 #ifndef Foundation_Exception_INCLUDED
00040 #define Foundation_Exception_INCLUDED
00041 
00042 
00043 #include "Poco/Foundation.h"
00044 #include <stdexcept>
00045 
00046 
00047 namespace Poco {
00048 
00049 
00050 class Foundation_API Exception: public std::exception
00053 {
00054 public:
00055         Exception(const std::string& msg, int code = 0);
00057 
00058         Exception(const std::string& msg, const std::string& arg, int code = 0);
00060 
00061         Exception(const std::string& msg, const Exception& nested, int code = 0);
00064 
00065         Exception(const Exception& exc);
00067                 
00068         ~Exception() throw();
00070 
00071         Exception& operator = (const Exception& exc);
00073 
00074         virtual const char* name() const throw();
00076                 
00077         virtual const char* className() const throw();
00079                 
00080         virtual const char* what() const throw();
00084                 
00085         const Exception* nested() const;
00088                         
00089         const std::string& message() const;
00091                         
00092         int code() const;
00094                 
00095         std::string displayText() const;
00098 
00099         virtual Exception* clone() const;
00104                 
00105         virtual void rethrow() const;
00111 
00112 protected:
00113         Exception(int code = 0);
00115                 
00116 private:
00117         std::string _msg;
00118         Exception*  _pNested;
00119         int                     _code;
00120 };
00121 
00122 
00123 //
00124 // inlines
00125 //
00126 inline const Exception* Exception::nested() const
00127 {
00128         return _pNested;
00129 }
00130 
00131 
00132 inline const std::string& Exception::message() const
00133 {
00134         return _msg;
00135 }
00136 
00137 
00138 inline int Exception::code() const
00139 {
00140         return _code;
00141 }
00142 
00143 
00144 //
00145 // Macros for quickly declaring and implementing exception classes.
00146 // Unfortunately, we cannot use a template here because character
00147 // pointers (which we need for specifying the exception name)
00148 // are not allowed as template arguments.
00149 //
00150 #define POCO_DECLARE_EXCEPTION(API, CLS, BASE) \
00151         class API CLS: public BASE                                                                                                              \
00152         {                                                                                                                                                               \
00153         public:                                                                                                                                                 \
00154                 CLS(int code = 0);                                                                                                                      \
00155                 CLS(const std::string& msg, int code = 0);                                                                      \
00156                 CLS(const std::string& msg, const std::string& arg, int code = 0);                      \
00157                 CLS(const std::string& msg, const Poco::Exception& exc, int code = 0);          \
00158                 CLS(const CLS& exc);                                                                                                            \
00159                 ~CLS() throw();                                                                                                                         \
00160                 CLS& operator = (const CLS& exc);                                                                                       \
00161                 const char* name() const throw();                                                                                       \
00162                 const char* className() const throw();                                                                          \
00163                 Poco::Exception* clone() const;                                                                                         \
00164                 void rethrow() const;                                                                                                           \
00165         };
00166 
00167 
00168 #define POCO_IMPLEMENT_EXCEPTION(CLS, BASE, NAME)                                                                                                       \
00169         CLS::CLS(int code): BASE(code)                                                                                                                                  \
00170         {                                                                                                                                                                                               \
00171         }                                                                                                                                                                                               \
00172         CLS::CLS(const std::string& msg, int code): BASE(msg, code)                                                                             \
00173         {                                                                                                                                                                                               \
00174         }                                                                                                                                                                                               \
00175         CLS::CLS(const std::string& msg, const std::string& arg, int code): BASE(msg, arg, code)                \
00176         {                                                                                                                                                                                               \
00177         }                                                                                                                                                                                               \
00178         CLS::CLS(const std::string& msg, const Poco::Exception& exc, int code): BASE(msg, exc, code)    \
00179         {                                                                                                                                                                                               \
00180         }                                                                                                                                                                                               \
00181         CLS::CLS(const CLS& exc): BASE(exc)                                                                                                                             \
00182         {                                                                                                                                                                                               \
00183         }                                                                                                                                                                                               \
00184         CLS::~CLS() throw()                                                                                                                                                             \
00185         {                                                                                                                                                                                               \
00186         }                                                                                                                                                                                               \
00187         CLS& CLS::operator = (const CLS& exc)                                                                                                                   \
00188         {                                                                                                                                                                                               \
00189                 BASE::operator = (exc);                                                                                                                                         \
00190                 return *this;                                                                                                                                                           \
00191         }                                                                                                                                                                                               \
00192         const char* CLS::name() const throw()                                                                                                                   \
00193         {                                                                                                                                                                                               \
00194                 return NAME;                                                                                                                                                            \
00195         }                                                                                                                                                                                               \
00196         const char* CLS::className() const throw()                                                                                                              \
00197         {                                                                                                                                                                                               \
00198                 return typeid(*this).name();                                                                                                                            \
00199         }                                                                                                                                                                                               \
00200         Poco::Exception* CLS::clone() const                                                                                                                             \
00201         {                                                                                                                                                                                               \
00202                 return new CLS(*this);                                                                                                                                          \
00203         }                                                                                                                                                                                               \
00204         void CLS::rethrow() const                                                                                                                                               \
00205         {                                                                                                                                                                                               \
00206                 throw *this;                                                                                                                                                            \
00207         }
00208 
00209 
00210 //
00211 // Standard exception classes
00212 //
00213 POCO_DECLARE_EXCEPTION(Foundation_API, LogicException, Exception)
00214 POCO_DECLARE_EXCEPTION(Foundation_API, AssertionViolationException, LogicException)
00215 POCO_DECLARE_EXCEPTION(Foundation_API, NullPointerException, LogicException)
00216 POCO_DECLARE_EXCEPTION(Foundation_API, BugcheckException, LogicException)
00217 POCO_DECLARE_EXCEPTION(Foundation_API, InvalidArgumentException, LogicException)
00218 POCO_DECLARE_EXCEPTION(Foundation_API, NotImplementedException, LogicException)
00219 POCO_DECLARE_EXCEPTION(Foundation_API, RangeException, LogicException)
00220 POCO_DECLARE_EXCEPTION(Foundation_API, IllegalStateException, LogicException)
00221 POCO_DECLARE_EXCEPTION(Foundation_API, InvalidAccessException, LogicException)
00222 POCO_DECLARE_EXCEPTION(Foundation_API, SignalException, LogicException)
00223 POCO_DECLARE_EXCEPTION(Foundation_API, UnhandledException, LogicException)
00224 
00225 POCO_DECLARE_EXCEPTION(Foundation_API, RuntimeException, Exception)
00226 POCO_DECLARE_EXCEPTION(Foundation_API, NotFoundException, RuntimeException)
00227 POCO_DECLARE_EXCEPTION(Foundation_API, ExistsException, RuntimeException)
00228 POCO_DECLARE_EXCEPTION(Foundation_API, TimeoutException, RuntimeException)
00229 POCO_DECLARE_EXCEPTION(Foundation_API, SystemException, RuntimeException)
00230 POCO_DECLARE_EXCEPTION(Foundation_API, RegularExpressionException, RuntimeException)
00231 POCO_DECLARE_EXCEPTION(Foundation_API, LibraryLoadException, RuntimeException)
00232 POCO_DECLARE_EXCEPTION(Foundation_API, LibraryAlreadyLoadedException, RuntimeException)
00233 POCO_DECLARE_EXCEPTION(Foundation_API, NoThreadAvailableException, RuntimeException)
00234 POCO_DECLARE_EXCEPTION(Foundation_API, PropertyNotSupportedException, RuntimeException)
00235 POCO_DECLARE_EXCEPTION(Foundation_API, PoolOverflowException, RuntimeException)
00236 POCO_DECLARE_EXCEPTION(Foundation_API, NoPermissionException, RuntimeException)
00237 POCO_DECLARE_EXCEPTION(Foundation_API, OutOfMemoryException, RuntimeException)
00238 POCO_DECLARE_EXCEPTION(Foundation_API, DataException, RuntimeException)
00239 
00240 POCO_DECLARE_EXCEPTION(Foundation_API, DataFormatException, DataException)
00241 POCO_DECLARE_EXCEPTION(Foundation_API, SyntaxException, DataException)
00242 POCO_DECLARE_EXCEPTION(Foundation_API, CircularReferenceException, DataException)
00243 POCO_DECLARE_EXCEPTION(Foundation_API, PathSyntaxException, SyntaxException)
00244 POCO_DECLARE_EXCEPTION(Foundation_API, IOException, RuntimeException)
00245 POCO_DECLARE_EXCEPTION(Foundation_API, FileException, IOException)
00246 POCO_DECLARE_EXCEPTION(Foundation_API, FileExistsException, FileException)
00247 POCO_DECLARE_EXCEPTION(Foundation_API, FileNotFoundException, FileException)
00248 POCO_DECLARE_EXCEPTION(Foundation_API, PathNotFoundException, FileException)
00249 POCO_DECLARE_EXCEPTION(Foundation_API, FileReadOnlyException, FileException)
00250 POCO_DECLARE_EXCEPTION(Foundation_API, FileAccessDeniedException, FileException)
00251 POCO_DECLARE_EXCEPTION(Foundation_API, CreateFileException, FileException)
00252 POCO_DECLARE_EXCEPTION(Foundation_API, OpenFileException, FileException)
00253 POCO_DECLARE_EXCEPTION(Foundation_API, WriteFileException, FileException)
00254 POCO_DECLARE_EXCEPTION(Foundation_API, ReadFileException, FileException)
00255 POCO_DECLARE_EXCEPTION(Foundation_API, UnknownURISchemeException, RuntimeException)
00256 
00257 POCO_DECLARE_EXCEPTION(Foundation_API, ApplicationException, Exception)
00258 POCO_DECLARE_EXCEPTION(Foundation_API, BadCastException, RuntimeException)
00259 
00260 
00261 } // namespace Poco
00262 
00263 
00264 #endif // Foundation_Exception_INCLUDED


pluginlib
Author(s): Tully Foote and Eitan Marder-Eppstein
autogenerated on Sat Dec 28 2013 17:20:19