fix: prefer reporting error over status for 200 OK (#5378)

This commit is contained in:
nerix
2024-05-05 19:37:22 +02:00
committed by GitHub
parent 401feac0aa
commit 56fa973d7c
3 changed files with 22 additions and 3 deletions
+10 -1
View File
@@ -67,7 +67,9 @@ const QByteArray &NetworkResult::getData() const
QString NetworkResult::formatError() const
{
if (this->status_)
// Print the status for errors that mirror HTTP status codes (=0 || >99)
if (this->status_ && (this->error_ == QNetworkReply::NoError ||
this->error_ > QNetworkReply::UnknownNetworkError))
{
return QString::number(*this->status_);
}
@@ -77,6 +79,13 @@ QString NetworkResult::formatError() const
this->error_);
if (name == nullptr)
{
if (this->status_)
{
return QStringLiteral("unknown error (status: %1, error: %2)")
.arg(QString::number(*this->status_),
QString::number(this->error_));
}
return QStringLiteral("unknown error (%1)").arg(this->error_);
}
return name;