Tidal: Show API error instead of network error when available

This commit is contained in:
Jonas Kvinge 2020-08-09 01:50:03 +02:00
parent ab7d383cf1
commit 5ec33ec821
1 changed files with 7 additions and 5 deletions

View File

@ -112,11 +112,13 @@ QByteArray TidalBaseRequest::GetReplyData(QNetworkReply *reply, const bool send_
error = QString("%1 (%2) (%3)").arg(user_message).arg(status).arg(sub_status);
}
}
if (reply->error() != QNetworkReply::NoError) {
error = QString("%1 (%2)").arg(reply->errorString()).arg(reply->error());
}
else {
error = QString("Received HTTP code %1").arg(reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt());
if (error.isEmpty()) {
if (reply->error() != QNetworkReply::NoError) {
error = QString("%1 (%2)").arg(reply->errorString()).arg(reply->error());
}
else {
error = QString("Received HTTP code %1").arg(reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt());
}
}
if (status == 401 && sub_status == 6001) { // User does not have a valid session
emit service_->Logout();