From a1aa74e5edb90266637c529dd96dd3487ac7d712 Mon Sep 17 00:00:00 2001 From: Stefan Suhren Date: Fri, 4 Sep 2015 20:56:41 +0200 Subject: FÃge CryptException zur Fehlerbehandlung hinzu MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- crypt/cryptexception.cpp | 23 +++++++++++++++++++++++ crypt/cryptexception.h | 43 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+) create mode 100644 crypt/cryptexception.cpp create mode 100644 crypt/cryptexception.h (limited to 'crypt') 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 +#include + +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 -- cgit v1.2.3-70-g09d2