more error tracing; refs #22
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
// 45678901234567890123456789012345678901234567890123456789012345678901234567890
|
||||
|
||||
#include <QtNetwork/QNetworkReply>
|
||||
#include <QtNetwork/QSslError>
|
||||
#include <map>
|
||||
|
||||
#include <cassert>
|
||||
@@ -24,6 +25,79 @@ class DownloadManager: public QObject {
|
||||
return *this;
|
||||
}
|
||||
|
||||
static QString networkError(QNetworkReply::NetworkError err) {
|
||||
LOG<<err;
|
||||
switch (err) {
|
||||
case QNetworkReply::NoError:
|
||||
return tr("Network connection successful, remote host can be"
|
||||
" reached.");
|
||||
case QNetworkReply::ConnectionRefusedError:
|
||||
return tr("The remote server refused the connection (the server is"
|
||||
" not accepting requests).");
|
||||
case QNetworkReply::RemoteHostClosedError:
|
||||
return tr("The remote server closed the connection prematurely,"
|
||||
" before the entire reply was received and processed.");
|
||||
case QNetworkReply::HostNotFoundError:
|
||||
return tr("The remote host name was not found (invalid hostname).");
|
||||
case QNetworkReply::TimeoutError:
|
||||
return tr("The connection to the remote server timed out.");
|
||||
case QNetworkReply::OperationCanceledError:
|
||||
return tr("The operation was canceled via calls to abort() or"
|
||||
" close() before it was finished.");
|
||||
case QNetworkReply::SslHandshakeFailedError:
|
||||
return tr("The SSL/TLS handshake failed and the encrypted channel"
|
||||
" could not be established. The sslErrors() signal should"
|
||||
" have been emitted.");
|
||||
case QNetworkReply::ProxyConnectionRefusedError:
|
||||
return tr("The connection to the proxy server was refused (the"
|
||||
" proxy server is not accepting requests).");
|
||||
case QNetworkReply::ProxyConnectionClosedError:
|
||||
return tr("The proxy server closed the connection prematurely,"
|
||||
" before the entire reply was received and processed.");
|
||||
case QNetworkReply::ProxyNotFoundError:
|
||||
return tr("The proxy host name was not found (invalid proxy"
|
||||
" hostname).");
|
||||
case QNetworkReply::ProxyTimeoutError:
|
||||
return tr("The connection to the proxy timed out or the proxy did"
|
||||
" not reply in time to the request sent.");
|
||||
case QNetworkReply::ProxyAuthenticationRequiredError:
|
||||
return tr("The proxy requires authentication in order to honour the"
|
||||
" request but did not accept any credentials offered"
|
||||
" (if any).");
|
||||
case QNetworkReply::ContentAccessDenied:
|
||||
return tr("The access to the remote content was denied (similar to"
|
||||
" HTTP error 401).");
|
||||
case QNetworkReply::ContentOperationNotPermittedError:
|
||||
return tr("The operation requested on the remote content is not"
|
||||
" permitted.");
|
||||
case QNetworkReply::ContentNotFoundError:
|
||||
return tr("The remote content was not found at the server (similar"
|
||||
" to HTTP error 404).");
|
||||
case QNetworkReply::AuthenticationRequiredError:
|
||||
return tr("The remote server requires authentication to serve the"
|
||||
" content but the credentials provided were not accepted"
|
||||
" (if any).");
|
||||
case QNetworkReply::ProtocolUnknownError:
|
||||
return tr("The Network Access API cannot honor the request because"
|
||||
" the protocol is not known.");
|
||||
case QNetworkReply::ProtocolInvalidOperationError:
|
||||
return tr("The requested operation is invalid for this protocol.");
|
||||
case QNetworkReply::UnknownNetworkError:
|
||||
return tr("An unknown network-related error was detected.");
|
||||
case QNetworkReply::UnknownProxyError:
|
||||
return tr("An unknown proxy-related error was detected.");
|
||||
case QNetworkReply::UnknownContentError:
|
||||
return tr("An unknonwn error related to the remote content was"
|
||||
" detected.");
|
||||
case QNetworkReply::ProtocolFailure:
|
||||
return tr("A breakdown in protocol was detected (parsing error,"
|
||||
" invalid or unexpected responses, etc.).");
|
||||
default:
|
||||
return tr("<strong>Unknown network error (code: %1).</string>")
|
||||
.arg(err);
|
||||
}
|
||||
}
|
||||
|
||||
Q_SIGNALS:
|
||||
|
||||
void progress(qint64 done, qint64 total);
|
||||
@@ -77,7 +151,7 @@ class DownloadManager: public QObject {
|
||||
calcProgress();
|
||||
}
|
||||
void error(QNetworkReply::NetworkError code) {
|
||||
LOG;
|
||||
LOG<<"Status:"<<networkError(code);
|
||||
}
|
||||
void slotFinished() {
|
||||
LOG;
|
||||
@@ -89,6 +163,9 @@ class DownloadManager: public QObject {
|
||||
}
|
||||
void sslErrors(const QList<QSslError> & errors) {
|
||||
LOG;
|
||||
for (QList<QSslError>::const_iterator err(errors.begin());
|
||||
err!=errors.end(); ++err)
|
||||
LOG<<"SSL-Error: "<<err->errorString();
|
||||
}
|
||||
void uploadProgress(qint64 bytesSent, qint64 bytesTotal) {
|
||||
//LOG<<bytesSent<<bytesTotal;
|
||||
|
Reference in New Issue
Block a user