From ac73ca1d2a23d3b62cca20545e019355f9d00035 Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Thu, 20 Apr 2017 14:59:59 +0200 Subject: Handle host not found --- examples/imapresource/imapserverproxy.cpp | 10 +++++++--- examples/imapresource/imapserverproxy.h | 1 + 2 files changed, 8 insertions(+), 3 deletions(-) (limited to 'examples/imapresource') diff --git a/examples/imapresource/imapserverproxy.cpp b/examples/imapresource/imapserverproxy.cpp index 0cc43b8..3305f60 100644 --- a/examples/imapresource/imapserverproxy.cpp +++ b/examples/imapresource/imapserverproxy.cpp @@ -161,12 +161,16 @@ KAsync::Job ImapServerProxy::login(const QString &username, const QString // SinkTrace() << "Found user namespaces: " << mNamespaces.user; }).then([=] (const KAsync::Error &error) { if (error) { - if (error.errorCode == KIMAP2::LoginJob::ErrorCode::ERR_COULD_NOT_CONNECT) { + switch (error.errorCode) { + case KIMAP2::LoginJob::ErrorCode::ERR_HOST_NOT_FOUND: + return KAsync::error(HostNotFoundError, "Host not found: " + error.errorMessage); + case KIMAP2::LoginJob::ErrorCode::ERR_COULD_NOT_CONNECT: return KAsync::error(CouldNotConnectError, "Failed to connect: " + error.errorMessage); - } else if (error.errorCode == KIMAP2::LoginJob::ErrorCode::ERR_SSL_HANDSHAKE_FAILED) { + case KIMAP2::LoginJob::ErrorCode::ERR_SSL_HANDSHAKE_FAILED: return KAsync::error(SslHandshakeError, "Ssl handshake failed: " + error.errorMessage); + default: + return KAsync::error(error); } - return KAsync::error(error); } return KAsync::null(); }); diff --git a/examples/imapresource/imapserverproxy.h b/examples/imapresource/imapserverproxy.h index 872f032..58c49a2 100644 --- a/examples/imapresource/imapserverproxy.h +++ b/examples/imapresource/imapserverproxy.h @@ -31,6 +31,7 @@ namespace Imap { enum ErrorCode { NoError, + HostNotFoundError, CouldNotConnectError, SslHandshakeError }; -- cgit v1.2.3