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

View File

@@ -112,12 +112,14 @@ QByteArray TidalBaseRequest::GetReplyData(QNetworkReply *reply, const bool send_
error = QString("%1 (%2) (%3)").arg(user_message).arg(status).arg(sub_status); error = QString("%1 (%2) (%3)").arg(user_message).arg(status).arg(sub_status);
} }
} }
if (error.isEmpty()) {
if (reply->error() != QNetworkReply::NoError) { if (reply->error() != QNetworkReply::NoError) {
error = QString("%1 (%2)").arg(reply->errorString()).arg(reply->error()); error = QString("%1 (%2)").arg(reply->errorString()).arg(reply->error());
} }
else { else {
error = QString("Received HTTP code %1").arg(reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt()); 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 if (status == 401 && sub_status == 6001) { // User does not have a valid session
emit service_->Logout(); emit service_->Logout();
if (!oauth() && send_login && login_attempts() < max_login_attempts() && !api_token().isEmpty() && !username().isEmpty() && !password().isEmpty()) { if (!oauth() && send_login && login_attempts() < max_login_attempts() && !api_token().isEmpty() && !username().isEmpty() && !password().isEmpty()) {