mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 03:24:00 +02:00
Clean up failResponse to make it better
This commit is contained in:
parent
af5a68b282
commit
0c48ccefa4
2 changed files with 15 additions and 12 deletions
|
@ -51,7 +51,7 @@ Rectangle {
|
|||
|
||||
onCertificateInfoResult: {
|
||||
if (result.status !== 'success') {
|
||||
console.log("Failed to get certificate info", result.message);
|
||||
console.log("Failed to get certificate info", result.data.message);
|
||||
// We should still tell the user that static cert verification failed
|
||||
if (root.certificateStatus !== 3) { // CERTIFICATE_STATUS_STATIC_VERIFICATION_FAILED
|
||||
root.useGoldCert = false;
|
||||
|
|
|
@ -35,12 +35,19 @@ QJsonObject Ledger::apiResponse(const QString& label, QNetworkReply& reply) {
|
|||
QJsonObject Ledger::failResponse(const QString& label, QNetworkReply& reply) {
|
||||
QString response = reply.readAll();
|
||||
qWarning(commerce) << "FAILED" << label << response;
|
||||
QJsonObject result
|
||||
{
|
||||
{ "status", "fail" },
|
||||
{ "message", response }
|
||||
};
|
||||
return result;
|
||||
|
||||
// tempResult will be NULL if the response isn't valid JSON.
|
||||
QJsonDocument tempResult = QJsonDocument::fromJson(response.toLocal8Bit());
|
||||
if (tempResult.isNull()) {
|
||||
QJsonObject result
|
||||
{
|
||||
{ "status", "fail" },
|
||||
{ "message", response }
|
||||
};
|
||||
return result;
|
||||
} else {
|
||||
return tempResult.object();
|
||||
}
|
||||
}
|
||||
#define ApiHandler(NAME) void Ledger::NAME##Success(QNetworkReply& reply) { emit NAME##Result(apiResponse(#NAME, reply)); }
|
||||
#define FailHandler(NAME) void Ledger::NAME##Failure(QNetworkReply& reply) { emit NAME##Result(failResponse(#NAME, reply)); }
|
||||
|
@ -338,11 +345,7 @@ void Ledger::certificateInfoSuccess(QNetworkReply& reply) {
|
|||
emit certificateInfoResult(replyObject);
|
||||
}
|
||||
void Ledger::certificateInfoFailure(QNetworkReply& reply) {
|
||||
QByteArray response = reply.readAll();
|
||||
QJsonObject replyObject = QJsonDocument::fromJson(response).object();
|
||||
|
||||
failResponse("certificateInfo", reply);
|
||||
emit certificateInfoResult(replyObject);
|
||||
emit certificateInfoResult(failResponse("certificateInfo", reply));
|
||||
}
|
||||
void Ledger::certificateInfo(const QString& certificateId) {
|
||||
QString endpoint = "proof_of_purchase_status/transfer";
|
||||
|
|
Loading…
Reference in a new issue