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 
00026 
00027 
00028 
00029 
00030 
00031 
00032 
00033 
00034 
00035 
00036 
00037 #include "Poco/Exception.h"
00038 #include <typeinfo>
00039 
00040 
00041 namespace Poco {
00042 
00043 
00044 Exception::Exception(int code): _pNested(0), _code(code)
00045 {
00046 }
00047 
00048 
00049 Exception::Exception(const std::string& msg, int code): _msg(msg), _pNested(0), _code(code)
00050 {
00051 }
00052 
00053 
00054 Exception::Exception(const std::string& msg, const std::string& arg, int code): _msg(msg), _pNested(0), _code(code)
00055 {
00056         if (!arg.empty())
00057         {
00058                 _msg.append(": ");
00059                 _msg.append(arg);
00060         }
00061 }
00062 
00063 
00064 Exception::Exception(const std::string& msg, const Exception& nested, int code): _msg(msg), _pNested(nested.clone()), _code(code)
00065 {
00066 }
00067 
00068 
00069 Exception::Exception(const Exception& exc):
00070         std::exception(exc),
00071         _msg(exc._msg),
00072         _code(exc._code)
00073 {
00074         _pNested = exc._pNested ? exc._pNested->clone() : 0;
00075 }
00076 
00077         
00078 Exception::~Exception() throw()
00079 {
00080         delete _pNested;
00081 }
00082 
00083 
00084 Exception& Exception::operator = (const Exception& exc)
00085 {
00086         if (&exc != this)
00087         {
00088                 delete _pNested;
00089                 _msg     = exc._msg;
00090                 _pNested = exc._pNested ? exc._pNested->clone() : 0;
00091                 _code    = exc._code;
00092         }
00093         return *this;
00094 }
00095 
00096 
00097 const char* Exception::name() const throw()
00098 {
00099         return "Exception";
00100 }
00101 
00102 
00103 const char* Exception::className() const throw()
00104 {
00105         return typeid(*this).name();
00106 }
00107 
00108         
00109 const char* Exception::what() const throw()
00110 {
00111         return name();
00112 }
00113 
00114         
00115 std::string Exception::displayText() const
00116 {
00117         std::string txt = name();
00118         if (!_msg.empty())
00119         {
00120                 txt.append(": ");
00121                 txt.append(_msg);
00122         }
00123         return txt;
00124 }
00125 
00126 
00127 Exception* Exception::clone() const
00128 {
00129         return new Exception(*this);
00130 }
00131 
00132 
00133 void Exception::rethrow() const
00134 {
00135         throw *this;
00136 }
00137 
00138 
00139 POCO_IMPLEMENT_EXCEPTION(LogicException, Exception, "Logic exception")
00140 POCO_IMPLEMENT_EXCEPTION(AssertionViolationException, LogicException, "Assertion violation")
00141 POCO_IMPLEMENT_EXCEPTION(NullPointerException, LogicException, "Null pointer")
00142 POCO_IMPLEMENT_EXCEPTION(BugcheckException, LogicException, "Bugcheck")
00143 POCO_IMPLEMENT_EXCEPTION(InvalidArgumentException, LogicException, "Invalid argument")
00144 POCO_IMPLEMENT_EXCEPTION(NotImplementedException, LogicException, "Not implemented")
00145 POCO_IMPLEMENT_EXCEPTION(RangeException, LogicException, "Out of range")
00146 POCO_IMPLEMENT_EXCEPTION(IllegalStateException, LogicException, "Illegal state")
00147 POCO_IMPLEMENT_EXCEPTION(InvalidAccessException, LogicException, "Invalid access")
00148 POCO_IMPLEMENT_EXCEPTION(SignalException, LogicException, "Signal received")
00149 POCO_IMPLEMENT_EXCEPTION(UnhandledException, LogicException, "Unhandled exception")
00150 
00151 POCO_IMPLEMENT_EXCEPTION(RuntimeException, Exception, "Runtime exception")
00152 POCO_IMPLEMENT_EXCEPTION(NotFoundException, RuntimeException, "Not found")
00153 POCO_IMPLEMENT_EXCEPTION(ExistsException, RuntimeException, "Exists")
00154 POCO_IMPLEMENT_EXCEPTION(TimeoutException, RuntimeException, "Timeout")
00155 POCO_IMPLEMENT_EXCEPTION(SystemException, RuntimeException, "System exception")
00156 POCO_IMPLEMENT_EXCEPTION(RegularExpressionException, RuntimeException, "Error in regular expression")
00157 POCO_IMPLEMENT_EXCEPTION(LibraryLoadException, RuntimeException, "Cannot load library")
00158 POCO_IMPLEMENT_EXCEPTION(LibraryAlreadyLoadedException, RuntimeException, "Library already loaded")
00159 POCO_IMPLEMENT_EXCEPTION(NoThreadAvailableException, RuntimeException, "No thread available")
00160 POCO_IMPLEMENT_EXCEPTION(PropertyNotSupportedException, RuntimeException, "Property not supported")
00161 POCO_IMPLEMENT_EXCEPTION(PoolOverflowException, RuntimeException, "Pool overflow")
00162 POCO_IMPLEMENT_EXCEPTION(NoPermissionException, RuntimeException, "No permission")
00163 POCO_IMPLEMENT_EXCEPTION(OutOfMemoryException, RuntimeException, "Out of memory")
00164 POCO_IMPLEMENT_EXCEPTION(DataException, RuntimeException, "Data error")
00165 
00166 POCO_IMPLEMENT_EXCEPTION(DataFormatException, DataException, "Bad data format")
00167 POCO_IMPLEMENT_EXCEPTION(SyntaxException, DataException, "Syntax error")
00168 POCO_IMPLEMENT_EXCEPTION(CircularReferenceException, DataException, "Circular reference")
00169 POCO_IMPLEMENT_EXCEPTION(PathSyntaxException, SyntaxException, "Bad path syntax")
00170 POCO_IMPLEMENT_EXCEPTION(IOException, RuntimeException, "I/O error")
00171 POCO_IMPLEMENT_EXCEPTION(FileException, IOException, "File access error")
00172 POCO_IMPLEMENT_EXCEPTION(FileExistsException, FileException, "File exists")
00173 POCO_IMPLEMENT_EXCEPTION(FileNotFoundException, FileException, "File not found")
00174 POCO_IMPLEMENT_EXCEPTION(PathNotFoundException, FileException, "Path not found")
00175 POCO_IMPLEMENT_EXCEPTION(FileReadOnlyException, FileException, "File is read-only")
00176 POCO_IMPLEMENT_EXCEPTION(FileAccessDeniedException, FileException, "Access to file denied")
00177 POCO_IMPLEMENT_EXCEPTION(CreateFileException, FileException, "Cannot create file")
00178 POCO_IMPLEMENT_EXCEPTION(OpenFileException, FileException, "Cannot open file")
00179 POCO_IMPLEMENT_EXCEPTION(WriteFileException, FileException, "Cannot write file")
00180 POCO_IMPLEMENT_EXCEPTION(ReadFileException, FileException, "Cannot read file")
00181 POCO_IMPLEMENT_EXCEPTION(UnknownURISchemeException, RuntimeException, "Unknown URI scheme")
00182 
00183 
00184 POCO_IMPLEMENT_EXCEPTION(ApplicationException, Exception, "Application exception")
00185 POCO_IMPLEMENT_EXCEPTION(BadCastException, RuntimeException, "Bad cast exception")
00186 
00187 }