diff options
author | Matthias Schiffer <matthias@gamezock.de> | 2008-09-19 11:15:14 +0200 |
---|---|---|
committer | Matthias Schiffer <matthias@gamezock.de> | 2008-09-19 11:15:14 +0200 |
commit | 113b1f4bbdecfab24ed9781b730a76a442adad6f (patch) | |
tree | e28f5c9a7a1afebd7d920f1006aacff401894dbc /src/Common/Exception.cpp | |
parent | 793a0789858734141dfa12d2ab3dd6ea3ed293e8 (diff) | |
download | mad-113b1f4bbdecfab24ed9781b730a76a442adad6f.tar mad-113b1f4bbdecfab24ed9781b730a76a442adad6f.zip |
Exceptions vereinheitlicht
Diffstat (limited to 'src/Common/Exception.cpp')
-rw-r--r-- | src/Common/Exception.cpp | 34 |
1 files changed, 25 insertions, 9 deletions
diff --git a/src/Common/Exception.cpp b/src/Common/Exception.cpp index 002ba82..dc04f7d 100644 --- a/src/Common/Exception.cpp +++ b/src/Common/Exception.cpp @@ -19,25 +19,41 @@ #include "Exception.h" +#include <cstring> +#include <gnutls/gnutls.h> + namespace Mad { namespace Common { -const char* Exception::strerror() const { +std::string Exception::strerror() const { + std::string ret; + + if(!where.empty()) + ret = where + ": "; + switch(errorCode) { case SUCCESS: - return "Success"; + return ret + "Success"; case UNEXPECTED_PACKET: - return "An unexpected packet was received"; + return ret + "An unexpected packet was received"; case INVALID_ACTION: - return "The action is invalid"; + return ret + "The action is invalid"; + case NOT_AVAILABLE: + return ret + "Not available"; + case NOT_FINISHED: + return ret + "Not finished"; + case INTERNAL_ERRNO: + return ret + "Internal error: " + std::strerror(subCode); + case INTERNAL_GNUTLS: + return ret + "GnuTLS error: " + gnutls_strerror(subCode); + case INVALID_ADDRESS: + return ret + "Invalid address"; case ALREADY_IDENTIFIED: - return "The host is already identified"; + return ret + "The host is already identified"; case UNKNOWN_DAEMON: - return "The daemon is unknown"; - case DAEMON_INACTIVE: - return "The daemon is inactive"; + return ret + "The daemon is unknown"; default: - return "Unknown error"; + return ret + "Unknown error"; } } |