mirror of
https://github.com/clementine-player/Clementine
synced 2024-12-25 09:10:49 +01:00
Handle error in SoundCloud replies
This commit is contained in:
parent
51385cc801
commit
beb5f9fa30
@ -203,7 +203,9 @@ void SoundCloudService::Logout() {
|
|||||||
|
|
||||||
access_token_.clear();
|
access_token_.clear();
|
||||||
s.remove("access_token");
|
s.remove("access_token");
|
||||||
|
if (user_activities_)
|
||||||
root_->removeRow(user_activities_->row());
|
root_->removeRow(user_activities_->row());
|
||||||
|
if (user_tracks_)
|
||||||
root_->removeRow(user_tracks_->row());
|
root_->removeRow(user_tracks_->row());
|
||||||
user_activities_ = nullptr;
|
user_activities_ = nullptr;
|
||||||
user_tracks_ = nullptr;
|
user_tracks_ = nullptr;
|
||||||
@ -357,6 +359,17 @@ QNetworkReply* SoundCloudService::CreateRequest(const QString& ressource_name,
|
|||||||
}
|
}
|
||||||
|
|
||||||
QVariant SoundCloudService::ExtractResult(QNetworkReply* reply) {
|
QVariant SoundCloudService::ExtractResult(QNetworkReply* reply) {
|
||||||
|
if (reply->error() != QNetworkReply::NoError) {
|
||||||
|
qLog(Debug) << "Error when retrieving SoundCloud results:" << reply->errorString() << QString(" (%1)").arg(reply->error());
|
||||||
|
if (reply->error() == QNetworkReply::ContentAccessDenied ||
|
||||||
|
reply->error() == QNetworkReply::ContentOperationNotPermittedError ||
|
||||||
|
reply->error() == QNetworkReply::ContentNotFoundError ||
|
||||||
|
reply->error() == QNetworkReply::AuthenticationRequiredError) {
|
||||||
|
// In case of access denied errors (invalid token?) logout
|
||||||
|
Logout();
|
||||||
|
return QVariant();
|
||||||
|
}
|
||||||
|
}
|
||||||
QJson::Parser parser;
|
QJson::Parser parser;
|
||||||
bool ok;
|
bool ok;
|
||||||
QVariant result = parser.parse(reply, &ok);
|
QVariant result = parser.parse(reply, &ok);
|
||||||
|
Loading…
Reference in New Issue
Block a user