Exception.cpp
Go to the documentation of this file.
00001 //
00002 // Exception.cpp
00003 //
00004 // $Id: //poco/1.3/Foundation/src/Exception.cpp#4 $
00005 //
00006 // Library: Foundation
00007 // Package: Core
00008 // Module:  Exception
00009 //
00010 // Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
00011 // and Contributors.
00012 //
00013 // Permission is hereby granted, free of charge, to any person or organization
00014 // obtaining a copy of the software and accompanying documentation covered by
00015 // this license (the "Software") to use, reproduce, display, distribute,
00016 // execute, and transmit the Software, and to prepare derivative works of the
00017 // Software, and to permit third-parties to whom the Software is furnished to
00018 // do so, all subject to the following:
00019 // 
00020 // The copyright notices in the Software and this entire statement, including
00021 // the above license grant, this restriction and the following disclaimer,
00022 // must be included in all copies of the Software, in whole or in part, and
00023 // all derivative works of the Software, unless such copies or derivative
00024 // works are solely in the form of machine-executable object code generated by
00025 // a source language processor.
00026 // 
00027 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
00028 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00029 // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
00030 // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
00031 // FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
00032 // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
00033 // DEALINGS IN THE SOFTWARE.
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 } // namespace Poco


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