1
0
mirror of https://github.com/strawberrymusicplayer/strawberry synced 2024-12-17 02:59:03 +01:00

Show Json parse error

This commit is contained in:
Jonas Kvinge 2020-05-10 12:48:48 +02:00
parent fe3af3a676
commit dfecd0cd12
4 changed files with 10 additions and 14 deletions

View File

@ -244,7 +244,7 @@ void GeniusLyricsProvider::AccessTokenRequestFinished(QNetworkReply *reply) {
QJsonDocument json_doc = QJsonDocument::fromJson(data, &json_error);
if (json_error.error != QJsonParseError::NoError) {
AuthError("Authentication reply from server missing Json data.");
Error(QString("Failed to parse Json data in authentication reply: %1").arg(json_error.errorString()));
return;
}
@ -333,7 +333,7 @@ void GeniusLyricsProvider::HandleSearchReply(QNetworkReply *reply, const quint64
}
if (!json_obj.contains("meta")) {
Error("Json reply is missing meta.", json_obj);
Error("Json reply is missing meta object.", json_obj);
EndSearch(search);
return;
}

View File

@ -54,11 +54,11 @@ QJsonObject JsonLyricsProvider::ExtractJsonObj(const QByteArray &data) {
return QJsonObject();
}
QJsonParseError error;
QJsonDocument json_doc = QJsonDocument::fromJson(data, &error);
QJsonParseError json_error;
QJsonDocument json_doc = QJsonDocument::fromJson(data, &json_error);
if (error.error != QJsonParseError::NoError) {
Error(QString("Failed to parse json data: %1").arg(error.errorString()));
if (json_error.error != QJsonParseError::NoError) {
Error(QString("Failed to parse json data: %1").arg(json_error.errorString()));
return QJsonObject();
}

View File

@ -74,9 +74,7 @@ void LoloLyricsProvider::HandleSearchReply(QNetworkReply *reply, const quint64 i
reply->deleteLater();
QByteArray data;
QString failure_reason;
if (reply->error() != QNetworkReply::NoError) {
failure_reason = QString("%1 (%2)").arg(reply->errorString()).arg(reply->error());
if (reply->error() < 200) {
@ -89,7 +87,7 @@ void LoloLyricsProvider::HandleSearchReply(QNetworkReply *reply, const quint64 i
failure_reason = QString("Received HTTP code %1").arg(reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt());
}
data = reply->readAll();
QByteArray data = reply->readAll();
LyricsSearchResults results;
if (!data.isEmpty()) {

View File

@ -85,12 +85,10 @@ void MusixmatchLyricsProvider::HandleSearchReply(QNetworkReply *reply, const qui
LyricsSearchResults results;
if (reply->error() != QNetworkReply::NoError) {
if (reply->error() < 200) {
Error(QString("%1 (%2)").arg(reply->errorString()).arg(reply->error()));
emit SearchFinished(id, results);
return;
}
}
else if (reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt() != 200) {
Error(QString("Received HTTP code %1").arg(reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt()));
emit SearchFinished(id, results);