Exception.cpp

Go to the documentation of this file.
00001 /* ES40 emulator.
00002  * Copyright (C) 2007-2008 by the ES40 Emulator Project
00003  *
00004  * WWW    : http://sourceforge.net/projects/es40
00005  * E-mail : camiel@camicom.com
00006  * 
00007  * This program is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU General Public License
00009  * as published by the Free Software Foundation; either version 2
00010  * of the License, or (at your option) any later version.
00011  * 
00012  * This program is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  * 
00017  * You should have received a copy of the GNU General Public License
00018  * along with this program; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
00020  * 
00021  * Although this is not required, the author would appreciate being notified of, 
00022  * and receiving any modifications you may make to the source code that might serve
00023  * the general public.
00024  */
00025 
00037 //
00038 // Exception.cpp
00039 //
00040 // $Id: Exception.cpp,v 1.1 2008/03/31 19:13:30 iamcamiel Exp $
00041 //
00042 // Library: Foundation
00043 // Package: Core
00044 // Module:  Exception
00045 //
00046 // Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
00047 // and Contributors.
00048 //
00049 // Permission is hereby granted, free of charge, to any person or organization
00050 // obtaining a copy of the software and accompanying documentation covered by
00051 // this license (the "Software") to use, reproduce, display, distribute,
00052 // execute, and transmit the Software, and to prepare derivative works of the
00053 // Software, and to permit third-parties to whom the Software is furnished to
00054 // do so, all subject to the following:
00055 // 
00056 // The copyright notices in the Software and this entire statement, including
00057 // the above license grant, this restriction and the following disclaimer,
00058 // must be included in all copies of the Software, in whole or in part, and
00059 // all derivative works of the Software, unless such copies or derivative
00060 // works are solely in the form of machine-executable object code generated by
00061 // a source language processor.
00062 // 
00063 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
00064 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00065 // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
00066 // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
00067 // FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
00068 // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
00069 // DEALINGS IN THE SOFTWARE.
00070 //
00071 
00072 
00073 #include "VMS/Exception.h"
00074 #include <typeinfo>
00075 
00076 
00077 namespace Poco {
00078 
00079 
00080 Exception::Exception(int code): _pNested(0), _code(code)
00081 {
00082 }
00083 
00084 
00085 Exception::Exception(const std::string& msg, int code): _msg(msg), _pNested(0), _code(code)
00086 {
00087 }
00088 
00089 
00090 Exception::Exception(const std::string& msg, const std::string& arg, int code): _msg(msg), _pNested(0), _code(code)
00091 {
00092         if (!arg.empty())
00093         {
00094                 _msg.append(": ");
00095                 _msg.append(arg);
00096         }
00097 }
00098 
00099 
00100 Exception::Exception(const std::string& msg, const Exception& nested, int code): _msg(msg), _pNested(nested.clone()), _code(code)
00101 {
00102 }
00103 
00104 
00105 Exception::Exception(const Exception& exc):
00106         std::exception(exc),
00107         _msg(exc._msg),
00108         _code(exc._code)
00109 {
00110         _pNested = exc._pNested ? exc._pNested->clone() : 0;
00111 }
00112 
00113         
00114 Exception::~Exception() throw()
00115 {
00116         delete _pNested;
00117 }
00118 
00119 
00120 Exception& Exception::operator = (const Exception& exc)
00121 {
00122         if (&exc != this)
00123         {
00124                 delete _pNested;
00125                 _msg     = exc._msg;
00126                 _pNested = exc._pNested ? exc._pNested->clone() : 0;
00127                 _code    = exc._code;
00128         }
00129         return *this;
00130 }
00131 
00132 
00133 const char* Exception::name() const throw()
00134 {
00135         return "Exception";
00136 }
00137 
00138 
00139 const char* Exception::className() const throw()
00140 {
00141         return typeid(*this).name();
00142 }
00143 
00144         
00145 const char* Exception::what() const throw()
00146 {
00147         return name();
00148 }
00149 
00150         
00151 std::string Exception::displayText() const
00152 {
00153         std::string txt = name();
00154         if (!_msg.empty())
00155         {
00156                 txt.append(": ");
00157                 txt.append(_msg);
00158         }
00159         return txt;
00160 }
00161 
00162 
00163 Exception* Exception::clone() const
00164 {
00165         return new Exception(*this);
00166 }
00167 
00168 
00169 void Exception::rethrow() const
00170 {
00171         throw *this;
00172 }
00173 
00174 
00175 POCO_IMPLEMENT_EXCEPTION(LogicException, Exception, "Logic exception")
00176 POCO_IMPLEMENT_EXCEPTION(AssertionViolationException, LogicException, "Assertion violation")
00177 POCO_IMPLEMENT_EXCEPTION(NullPointerException, LogicException, "Null pointer")
00178 POCO_IMPLEMENT_EXCEPTION(BugcheckException, LogicException, "Bugcheck")
00179 POCO_IMPLEMENT_EXCEPTION(InvalidArgumentException, LogicException, "Invalid argument")
00180 POCO_IMPLEMENT_EXCEPTION(NotImplementedException, LogicException, "Not implemented")
00181 POCO_IMPLEMENT_EXCEPTION(RangeException, LogicException, "Out of range")
00182 POCO_IMPLEMENT_EXCEPTION(IllegalStateException, LogicException, "Illegal state")
00183 POCO_IMPLEMENT_EXCEPTION(InvalidAccessException, LogicException, "Invalid access")
00184 POCO_IMPLEMENT_EXCEPTION(SignalException, LogicException, "Signal received")
00185 POCO_IMPLEMENT_EXCEPTION(UnhandledException, LogicException, "Signal received")
00186 
00187 POCO_IMPLEMENT_EXCEPTION(RuntimeException, Exception, "Runtime exception")
00188 POCO_IMPLEMENT_EXCEPTION(NotFoundException, RuntimeException, "Not found")
00189 POCO_IMPLEMENT_EXCEPTION(ExistsException, RuntimeException, "Exists")
00190 POCO_IMPLEMENT_EXCEPTION(TimeoutException, RuntimeException, "Timeout")
00191 POCO_IMPLEMENT_EXCEPTION(SystemException, RuntimeException, "System exception")
00192 POCO_IMPLEMENT_EXCEPTION(RegularExpressionException, RuntimeException, "Error in regular expression")
00193 POCO_IMPLEMENT_EXCEPTION(LibraryLoadException, RuntimeException, "Cannot load library")
00194 POCO_IMPLEMENT_EXCEPTION(LibraryAlreadyLoadedException, RuntimeException, "Library already loaded")
00195 POCO_IMPLEMENT_EXCEPTION(NoThreadAvailableException, RuntimeException, "No thread available")
00196 POCO_IMPLEMENT_EXCEPTION(PropertyNotSupportedException, RuntimeException, "Property not supported")
00197 POCO_IMPLEMENT_EXCEPTION(PoolOverflowException, RuntimeException, "Pool overflow")
00198 POCO_IMPLEMENT_EXCEPTION(NoPermissionException, RuntimeException, "No permission")
00199 POCO_IMPLEMENT_EXCEPTION(OutOfMemoryException, RuntimeException, "Out of memory")
00200 POCO_IMPLEMENT_EXCEPTION(DataException, RuntimeException, "Data error")
00201 
00202 POCO_IMPLEMENT_EXCEPTION(DataFormatException, DataException, "Bad data format")
00203 POCO_IMPLEMENT_EXCEPTION(SyntaxException, DataException, "Syntax error")
00204 POCO_IMPLEMENT_EXCEPTION(CircularReferenceException, DataException, "Circular reference")
00205 POCO_IMPLEMENT_EXCEPTION(PathSyntaxException, SyntaxException, "Bad path syntax")
00206 POCO_IMPLEMENT_EXCEPTION(IOException, RuntimeException, "I/O error")
00207 POCO_IMPLEMENT_EXCEPTION(FileException, IOException, "File access error")
00208 POCO_IMPLEMENT_EXCEPTION(FileExistsException, FileException, "File exists")
00209 POCO_IMPLEMENT_EXCEPTION(FileNotFoundException, FileException, "File not found")
00210 POCO_IMPLEMENT_EXCEPTION(PathNotFoundException, FileException, "Path not found")
00211 POCO_IMPLEMENT_EXCEPTION(FileReadOnlyException, FileException, "File is read-only")
00212 POCO_IMPLEMENT_EXCEPTION(FileAccessDeniedException, FileException, "Access to file denied")
00213 POCO_IMPLEMENT_EXCEPTION(CreateFileException, FileException, "Cannot create file")
00214 POCO_IMPLEMENT_EXCEPTION(OpenFileException, FileException, "Cannot open file")
00215 POCO_IMPLEMENT_EXCEPTION(WriteFileException, FileException, "Cannot write file")
00216 POCO_IMPLEMENT_EXCEPTION(ReadFileException, FileException, "Cannot read file")
00217 POCO_IMPLEMENT_EXCEPTION(UnknownURISchemeException, RuntimeException, "Unknown URI scheme")
00218 
00219 
00220 POCO_IMPLEMENT_EXCEPTION(ApplicationException, Exception, "Application exception")
00221 POCO_IMPLEMENT_EXCEPTION(BadCastException, RuntimeException, "Bad cast exception")
00222 
00223 } // namespace Poco
00224 

SourceForge.net Logo
Project space on SourceForge.net