aboutsummaryrefslogtreecommitdiff
path: root/src/protocolhandler.cpp
diff options
context:
space:
mode:
authorFelix (xq) Queißner <git@mq32.de>2020-06-16 23:01:16 +0200
committerFelix (xq) Queißner <git@mq32.de>2020-06-16 23:01:16 +0200
commit94dbe30902e36cedb30cb89ea3bd7ecd6c5a03f2 (patch)
tree98b32b834960a59102118630f4d936671081f6c7 /src/protocolhandler.cpp
parenta3f3e3933c4a2522e233917a6795c6e9d677e65c (diff)
downloadkristall-94dbe30902e36cedb30cb89ea3bd7ecd6c5a03f2.tar.gz
Adds improved error handling.
Diffstat (limited to 'src/protocolhandler.cpp')
-rw-r--r--src/protocolhandler.cpp30
1 files changed, 29 insertions, 1 deletions
diff --git a/src/protocolhandler.cpp b/src/protocolhandler.cpp
index 5a87bac..6a3bd92 100644
--- a/src/protocolhandler.cpp
+++ b/src/protocolhandler.cpp
@@ -2,7 +2,6 @@
ProtocolHandler::ProtocolHandler(QObject *parent) : QObject(parent)
{
-
}
bool ProtocolHandler::enableClientCertificate(const CryptoIdentity &ident)
@@ -13,5 +12,34 @@ bool ProtocolHandler::enableClientCertificate(const CryptoIdentity &ident)
void ProtocolHandler::disableClientCertificate()
{
+}
+void ProtocolHandler::emitNetworkError(QAbstractSocket::SocketError error_code, const QString &textual_description)
+{
+ NetworkError network_error = UnknownError;
+ switch (error_code)
+ {
+ case QAbstractSocket::ConnectionRefusedError:
+ network_error = ConnectionRefused;
+ break;
+ case QAbstractSocket::HostNotFoundError:
+ network_error = HostNotFound;
+ break;
+ case QAbstractSocket::SocketTimeoutError:
+ network_error = Timeout;
+ break;
+ case QAbstractSocket::SslHandshakeFailedError:
+ network_error = TlsFailure;
+ break;
+ case QAbstractSocket::SslInternalError:
+ network_error = TlsFailure;
+ break;
+ case QAbstractSocket::SslInvalidUserDataError:
+ network_error = TlsFailure;
+ break;
+ default:
+ qDebug() << "unhandled network error:" << error_code;
+ break;
+ }
+ emit this->networkError(network_error, textual_description);
}