diff options
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"; } } |