diff options
| -rw-r--r-- | CryptLog.pro | 6 | ||||
| -rw-r--r-- | crypt/cryptexception.cpp | 23 | ||||
| -rw-r--r-- | crypt/cryptexception.h | 43 |
3 files changed, 70 insertions, 2 deletions
diff --git a/CryptLog.pro b/CryptLog.pro index f700754..7eee1d7 100644 --- a/CryptLog.pro +++ b/CryptLog.pro @@ -16,12 +16,14 @@ SOURCES += main.cpp\ mainwindow.cpp \ passworddialog.cpp \ publickeyimport.cpp \ - crypt/hybridcrypt.cpp + crypt/hybridcrypt.cpp \ + crypt/cryptexception.cpp HEADERS += mainwindow.h \ passworddialog.h \ publickeyimport.h \ - crypt/hybridcrypt.h + crypt/hybridcrypt.h \ + crypt/cryptexception.h FORMS += mainwindow.ui \ passworddialog.ui \ diff --git a/crypt/cryptexception.cpp b/crypt/cryptexception.cpp new file mode 100644 index 0000000..4cf2e6c --- /dev/null +++ b/crypt/cryptexception.cpp @@ -0,0 +1,23 @@ +#include "cryptexception.h" + +CryptException::CryptException(std::string what, int returnCode) + :exception() +{ + this->whatMsg = what; + this->retId = returnCode; +} + +CryptException::~CryptException() throw() +{ + +} + +const char *CryptException::what() const throw() +{ + return whatMsg.c_str(); +} + +int CryptException::returnCode() const +{ + return retId; +} diff --git a/crypt/cryptexception.h b/crypt/cryptexception.h new file mode 100644 index 0000000..1141969 --- /dev/null +++ b/crypt/cryptexception.h @@ -0,0 +1,43 @@ +#ifndef CRYPTEXCEPTION_H +#define CRYPTEXCEPTION_H + +#include <exception> +#include <QString> + +class CryptException : public std::exception +{ +public: + /** + * @brief CryptException + * Erzeugt eine Exception mit den angegebenen Werten. + * @param what Die Fehlermeldung, die dem Nutzer gezeigt wird. + * @param returnCode Der Rückgabewert für die Konsole. + */ + CryptException(std::string what, int returnCode); + + /** + * @brief ~CryptException + */ + virtual ~CryptException() throw(); + + /** + * @brief what + * Gibt die Fehlermelung für den Nutzer zurück. + * @return Die Fehlermeldung für den Nutzer. + */ + virtual const char *what() const throw(); + + /** + * @brief returnCode + * Gibt den Konsolenrückgabewert zurück. + * @return Der Rückgabewert für die Konsole. + */ + int returnCode() const; + +private: + std::string whatMsg; + int retId; + +}; + +#endif // CRYPTEXCEPTION_H |
