00001 // -*- c++ -*- 00002 // 00003 // $Id: yapetexception.h 2361 2009-06-11 15:06:39Z rafi $ 00004 // 00005 // Copyright (C) 2008, 2009 Rafael Ostertag 00006 // 00007 // This file is part of YAPET. 00008 // 00009 // YAPET is free software: you can redistribute it and/or modify it under the 00010 // terms of the GNU General Public License as published by the Free Software 00011 // Foundation, either version 3 of the License, or (at your option) any later 00012 // version. 00013 // 00014 // YAPET is distributed in the hope that it will be useful, but WITHOUT ANY 00015 // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 00016 // FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 00017 // details. 00018 // 00019 // You should have received a copy of the GNU General Public License along with 00020 // YAPET. If not, see <http://www.gnu.org/licenses/>. 00021 // 00022 // Additional permission under GNU GPL version 3 section 7 00023 // 00024 // If you modify this program, or any covered work, by linking or combining it 00025 // with the OpenSSL project's OpenSSL library (or a modified version of that 00026 // library), containing parts covered by the terms of the OpenSSL or SSLeay 00027 // licenses, Rafael Ostertag grants you additional permission to convey the 00028 // resulting work. Corresponding Source for a non-source form of such a 00029 // combination shall include the source code for the parts of OpenSSL used as 00030 // well as that of the covered work. 00031 // 00032 00033 #ifndef _YAPETEXCEPTION_H 00034 #define _YAPETEXCEPTION_H 00035 00036 #ifdef HAVE_CONFIG_H 00037 # include <config.h> 00038 #endif 00039 00040 #ifdef HAVE_EXCEPTION 00041 # include <exception> 00042 #endif 00043 00044 #ifdef HAVE_STRING 00045 # include <string> 00046 #endif 00047 00048 #include "../intl.h" 00049 00050 namespace YAPET { 00051 00057 class YAPETException : public std::exception { 00058 private: 00059 std::string message; 00060 00061 public: 00067 inline YAPETException() 00068 throw() : exception(), 00069 message(_("Generic exception message")) {} 00077 inline YAPETException(std::string msg) 00078 throw() : exception(), 00079 message(msg) {} 00080 inline YAPETException(const YAPETException& ex) throw() { 00081 message = ex.message; 00082 } 00083 inline virtual ~YAPETException() throw() { /* empty */ } 00084 inline const YAPETException& operator=(const YAPETException& ex) 00085 throw() { 00086 if (this == &ex) return *this; 00087 message = ex.message; 00088 return *this; 00089 } 00090 inline virtual const char* what() const throw() { 00091 return message.c_str(); 00092 } 00093 }; 00094 00103 class YAPETRetryException : public YAPETException { 00104 public: 00105 inline YAPETRetryException() 00106 throw() : YAPETException(_("Retry")) {} 00107 inline YAPETRetryException(std::string msg) 00108 throw() : YAPETException(msg) {} 00109 inline YAPETRetryException(const YAPETRetryException& ex) 00110 throw() : YAPETException(ex) {} 00111 inline virtual ~YAPETRetryException() throw() { /* Empty */ } 00112 00113 inline const YAPETRetryException 00114 operator=(const YAPETRetryException& ex) throw() { 00115 if (this == &ex) return *this; 00116 YAPETException::operator=(ex); 00117 return *this; 00118 } 00119 }; 00120 00127 class YAPETEncryptionException : public YAPETException { 00128 public: 00129 inline YAPETEncryptionException() 00130 throw() : YAPETException(_("Encryption error")) {} 00131 inline YAPETEncryptionException(std::string msg) 00132 throw() : YAPETException(msg) {} 00133 inline YAPETEncryptionException(const YAPETEncryptionException& ex) 00134 throw() : YAPETException(ex) {} 00135 inline virtual ~YAPETEncryptionException() throw() { /* Empty */ } 00136 00137 inline const YAPETEncryptionException 00138 operator=(const YAPETEncryptionException& ex) throw() { 00139 if (this == &ex) return *this; 00140 YAPETException::operator=(ex); 00141 return *this; 00142 } 00143 }; 00144 00153 class YAPETInvalidPasswordException : public YAPETException { 00154 public: 00155 inline YAPETInvalidPasswordException() 00156 throw() : YAPETException(_("Invalid password")) {} 00157 inline YAPETInvalidPasswordException(std::string msg) 00158 throw() : YAPETException(msg) {} 00159 00160 inline 00161 YAPETInvalidPasswordException(const YAPETInvalidPasswordException& ex) 00162 throw() : YAPETException(ex) {} 00163 inline virtual ~YAPETInvalidPasswordException() 00164 throw() { /* Empty */ } 00165 00166 inline const YAPETInvalidPasswordException 00167 operator=(const YAPETInvalidPasswordException& ex) throw() { 00168 if (this == &ex) return *this; 00169 YAPETException::operator=(ex); 00170 return *this; 00171 } 00172 }; 00173 00174 } 00175 00176 #endif // _YAPETEXCEPTION_H