I have basic function that prints network errors based on enum NetworkError.
that looks like this :
void HttpClient::HandleNetworkError(QNetworkReply::NetworkError& networkError)
{
switch(networkError)
{
case(QNetworkReply::ConnectionRefusedError):
LOG_MSG("NO NETWORK CONNECTION ConnectionRefusedError!! ");
break;
case(QNetworkReply::HostNotFoundError):
//handle the html output is no internet connection is found
LOG_MSG("NO NETWORK CONNECTION HostNotFoundError!! ");
break;
case(QNetworkReply::SslHandshakeFailedError):
//handle the html output is no internet connection is found
LOG_MSG("CONNECTION SslHandshakeFailedError!! ");
break;
case(QNetworkReply::UnknownContentError):
LOG_MSG("CONNECTION UnknownContentError!! ");
break;
default :
LOG_MSG("CONNECTION not defined default error UnknownContentError!! ");
}
}
now i need to support more errors , in fact all the error that list in enum NetworkError, so does it means i need to
added them all to this switch case ? or there is some kind of generic Qt functions that do this translation ?
This is already answered in the
QNetworkReply::error()signal documentation: