mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2023-10-10 13:36:59 +02:00
Handle network timeout before any other error
This commit is contained in:
parent
89eb3523c6
commit
bc8cecf19c
@ -296,13 +296,11 @@ httpResponse ProviderRestApi::getResponse(QNetworkReply* const& reply)
|
|||||||
if (error.error != QJsonParseError::NoError)
|
if (error.error != QJsonParseError::NoError)
|
||||||
{
|
{
|
||||||
//Received not valid JSON response
|
//Received not valid JSON response
|
||||||
//std::cout << "Response: [" << replyData.toStdString() << "]" << std::endl;
|
|
||||||
response.setError(true);
|
response.setError(true);
|
||||||
response.setErrorReason(error.errorString());
|
response.setErrorReason(error.errorString());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//std::cout << "Response: [" << QString(jsonDoc.toJson(QJsonDocument::Compact)).toStdString() << "]" << std::endl;
|
|
||||||
response.setBody(jsonDoc);
|
response.setBody(jsonDoc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -314,6 +312,13 @@ httpResponse ProviderRestApi::getResponse(QNetworkReply* const& reply)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
QString errorReason;
|
QString errorReason;
|
||||||
|
if (reply->error() == QNetworkReply::OperationCanceledError)
|
||||||
|
{
|
||||||
|
errorReason = "Network request timeout error";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
qDebug() << "httpStatusCode: "<< httpStatusCode;
|
||||||
if (httpStatusCode > 0) {
|
if (httpStatusCode > 0) {
|
||||||
QString httpReason = reply->attribute(QNetworkRequest::HttpReasonPhraseAttribute).toString();
|
QString httpReason = reply->attribute(QNetworkRequest::HttpReasonPhraseAttribute).toString();
|
||||||
QString advise;
|
QString advise;
|
||||||
@ -337,17 +342,11 @@ httpResponse ProviderRestApi::getResponse(QNetworkReply* const& reply)
|
|||||||
errorReason = QString ("[%3 %4] - %5").arg(httpStatusCode).arg(httpReason, advise);
|
errorReason = QString ("[%3 %4] - %5").arg(httpStatusCode).arg(httpReason, advise);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
|
||||||
if (reply->error() == QNetworkReply::OperationCanceledError)
|
|
||||||
{
|
|
||||||
errorReason = "Network request timeout error";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
errorReason = reply->errorString();
|
errorReason = reply->errorString();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
response.setError(true);
|
response.setError(true);
|
||||||
response.setErrorReason(errorReason);
|
response.setErrorReason(errorReason);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user