From 6fdb0756f722c5b3794b2813291148cf354c63e9 Mon Sep 17 00:00:00 2001 From: Nikita Baryshnikov Date: Tue, 5 Sep 2017 14:35:09 +0300 Subject: [PATCH] SshExceptions derive from std::exception Change-Id: Id107ed53fed9ff72e90b662dfc024c4ced24a89d Reviewed-by: Christian Kandeler --- src/libs/ssh/sshexception_p.h | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/libs/ssh/sshexception_p.h b/src/libs/ssh/sshexception_p.h index b51ce4b04c8..94697df19ed 100644 --- a/src/libs/ssh/sshexception_p.h +++ b/src/libs/ssh/sshexception_p.h @@ -31,6 +31,8 @@ #include #include +#include + namespace QSsh { namespace Internal { @@ -57,25 +59,28 @@ enum SshErrorCode { #define SSH_SERVER_EXCEPTION(error, errorString) \ SshServerException((error), (errorString), SSH_TR(errorString)) -struct SshServerException +struct SshServerException : public std::exception { SshServerException(SshErrorCode error, const QByteArray &errorStringServer, const QString &errorStringUser) : error(error), errorStringServer(errorStringServer), errorStringUser(errorStringUser) {} + const char *what() const noexcept override { return errorStringServer.constData(); } const SshErrorCode error; const QByteArray errorStringServer; const QString errorStringUser; }; -struct SshClientException +struct SshClientException : public std::exception { SshClientException(SshError error, const QString &errorString) - : error(error), errorString(errorString) {} + : error(error), errorString(errorString), errorStringPrintable(errorString.toLocal8Bit()) {} + const char *what() const noexcept override { return errorStringPrintable.constData(); } const SshError error; const QString errorString; + const QByteArray errorStringPrintable; }; } // namespace Internal