00001 // -*- c++ -*- 00002 // 00003 // $Id: yapetexception.h 2293 2009-04-11 16:01:50Z rafi $ 00004 // 00005 // YAPET -- Yet Another Password Encryption Tool 00006 // Copyright (C) 2008 Rafael Ostertag 00007 // 00008 // This program is free software: you can redistribute it and/or modify 00009 // it under the terms of the GNU General Public License as published by 00010 // the Free Software Foundation, either version 3 of the License, or 00011 // (at your option) any later version. 00012 // 00013 // This program is distributed in the hope that it will be useful, 00014 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00016 // GNU General Public License for more details. 00017 // 00018 // You should have received a copy of the GNU General Public License 00019 // along with this program. If not, see <http://www.gnu.org/licenses/>. 00020 // 00021 00022 #ifndef _YAPETEXCEPTION_H 00023 #define _YAPETEXCEPTION_H 00024 00025 #ifdef HAVE_CONFIG_H 00026 # include <config.h> 00027 #endif 00028 00029 #ifdef HAVE_EXCEPTION 00030 # include <exception> 00031 #endif 00032 00033 #ifdef HAVE_STRING 00034 # include <string> 00035 #endif 00036 00037 #include "../intl.h" 00038 00039 namespace YAPET { 00040 00046 class YAPETException : public std::exception { 00047 private: 00048 std::string message; 00049 00050 public: 00056 inline YAPETException() 00057 throw() : exception(), 00058 message(_("Generic exception message")) {} 00066 inline YAPETException(std::string msg) 00067 throw() : exception(), 00068 message(msg) {} 00069 inline YAPETException(const YAPETException& ex) throw() { 00070 message = ex.message; 00071 } 00072 inline virtual ~YAPETException() throw() { /* empty */ } 00073 inline const YAPETException& operator=(const YAPETException& ex) 00074 throw() { 00075 if (this == &ex) return *this; 00076 message = ex.message; 00077 return *this; 00078 } 00079 inline virtual const char* what() const throw() { 00080 return message.c_str(); 00081 } 00082 }; 00083 00092 class YAPETRetryException : public YAPETException { 00093 public: 00094 inline YAPETRetryException() 00095 throw() : YAPETException(_("Retry")) {} 00096 inline YAPETRetryException(std::string msg) 00097 throw() : YAPETException(msg) {} 00098 inline YAPETRetryException(const YAPETRetryException& ex) 00099 throw() : YAPETException(ex) {} 00100 inline virtual ~YAPETRetryException() throw() { /* Empty */ } 00101 00102 inline const YAPETRetryException 00103 operator=(const YAPETRetryException& ex) throw() { 00104 if (this == &ex) return *this; 00105 YAPETException::operator=(ex); 00106 return *this; 00107 } 00108 }; 00109 00116 class YAPETEncryptionException : public YAPETException { 00117 public: 00118 inline YAPETEncryptionException() 00119 throw() : YAPETException(_("Encryption error")) {} 00120 inline YAPETEncryptionException(std::string msg) 00121 throw() : YAPETException(msg) {} 00122 inline YAPETEncryptionException(const YAPETEncryptionException& ex) 00123 throw() : YAPETException(ex) {} 00124 inline virtual ~YAPETEncryptionException() throw() { /* Empty */ } 00125 00126 inline const YAPETEncryptionException 00127 operator=(const YAPETEncryptionException& ex) throw() { 00128 if (this == &ex) return *this; 00129 YAPETException::operator=(ex); 00130 return *this; 00131 } 00132 }; 00133 00142 class YAPETInvalidPasswordException : public YAPETException { 00143 public: 00144 inline YAPETInvalidPasswordException() 00145 throw() : YAPETException(_("Invalid password")) {} 00146 inline YAPETInvalidPasswordException(std::string msg) 00147 throw() : YAPETException(msg) {} 00148 00149 inline 00150 YAPETInvalidPasswordException(const YAPETInvalidPasswordException& ex) 00151 throw() : YAPETException(ex) {} 00152 inline virtual ~YAPETInvalidPasswordException() 00153 throw() { /* Empty */ } 00154 00155 inline const YAPETInvalidPasswordException 00156 operator=(const YAPETInvalidPasswordException& ex) throw() { 00157 if (this == &ex) return *this; 00158 YAPETException::operator=(ex); 00159 return *this; 00160 } 00161 }; 00162 00163 } 00164 00165 #endif // _YAPETEXCEPTION_H