Show Json parse error
This commit is contained in:
parent
fe3af3a676
commit
dfecd0cd12
@ -244,7 +244,7 @@ void GeniusLyricsProvider::AccessTokenRequestFinished(QNetworkReply *reply) {
|
|||||||
QJsonDocument json_doc = QJsonDocument::fromJson(data, &json_error);
|
QJsonDocument json_doc = QJsonDocument::fromJson(data, &json_error);
|
||||||
|
|
||||||
if (json_error.error != QJsonParseError::NoError) {
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -333,7 +333,7 @@ void GeniusLyricsProvider::HandleSearchReply(QNetworkReply *reply, const quint64
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!json_obj.contains("meta")) {
|
if (!json_obj.contains("meta")) {
|
||||||
Error("Json reply is missing meta.", json_obj);
|
Error("Json reply is missing meta object.", json_obj);
|
||||||
EndSearch(search);
|
EndSearch(search);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -54,11 +54,11 @@ QJsonObject JsonLyricsProvider::ExtractJsonObj(const QByteArray &data) {
|
|||||||
return QJsonObject();
|
return QJsonObject();
|
||||||
}
|
}
|
||||||
|
|
||||||
QJsonParseError error;
|
QJsonParseError json_error;
|
||||||
QJsonDocument json_doc = QJsonDocument::fromJson(data, &error);
|
QJsonDocument json_doc = QJsonDocument::fromJson(data, &json_error);
|
||||||
|
|
||||||
if (error.error != QJsonParseError::NoError) {
|
if (json_error.error != QJsonParseError::NoError) {
|
||||||
Error(QString("Failed to parse json data: %1").arg(error.errorString()));
|
Error(QString("Failed to parse json data: %1").arg(json_error.errorString()));
|
||||||
return QJsonObject();
|
return QJsonObject();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -74,9 +74,7 @@ void LoloLyricsProvider::HandleSearchReply(QNetworkReply *reply, const quint64 i
|
|||||||
|
|
||||||
reply->deleteLater();
|
reply->deleteLater();
|
||||||
|
|
||||||
QByteArray data;
|
|
||||||
QString failure_reason;
|
QString failure_reason;
|
||||||
|
|
||||||
if (reply->error() != QNetworkReply::NoError) {
|
if (reply->error() != QNetworkReply::NoError) {
|
||||||
failure_reason = QString("%1 (%2)").arg(reply->errorString()).arg(reply->error());
|
failure_reason = QString("%1 (%2)").arg(reply->errorString()).arg(reply->error());
|
||||||
if (reply->error() < 200) {
|
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());
|
failure_reason = QString("Received HTTP code %1").arg(reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt());
|
||||||
}
|
}
|
||||||
|
|
||||||
data = reply->readAll();
|
QByteArray data = reply->readAll();
|
||||||
LyricsSearchResults results;
|
LyricsSearchResults results;
|
||||||
|
|
||||||
if (!data.isEmpty()) {
|
if (!data.isEmpty()) {
|
||||||
|
@ -85,12 +85,10 @@ void MusixmatchLyricsProvider::HandleSearchReply(QNetworkReply *reply, const qui
|
|||||||
LyricsSearchResults results;
|
LyricsSearchResults results;
|
||||||
|
|
||||||
if (reply->error() != QNetworkReply::NoError) {
|
if (reply->error() != QNetworkReply::NoError) {
|
||||||
if (reply->error() < 200) {
|
|
||||||
Error(QString("%1 (%2)").arg(reply->errorString()).arg(reply->error()));
|
Error(QString("%1 (%2)").arg(reply->errorString()).arg(reply->error()));
|
||||||
emit SearchFinished(id, results);
|
emit SearchFinished(id, results);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else if (reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt() != 200) {
|
else if (reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt() != 200) {
|
||||||
Error(QString("Received HTTP code %1").arg(reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt()));
|
Error(QString("Received HTTP code %1").arg(reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt()));
|
||||||
emit SearchFinished(id, results);
|
emit SearchFinished(id, results);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user