Skip to content
Snippets Groups Projects
Commit 31e74b0a authored by Erdem Erdyniev's avatar Erdem Erdyniev
Browse files

[*]web3api:GetLedgerHash(): Fixed error parsing from node response

parent 10247aaa
No related branches found
No related tags found
2 merge requests!293[+] add new web 3 commands - GetDexOrderList, GetDexPairs, GetDexPairRate,!289bugfix-15119
...@@ -26,9 +26,35 @@ QVariant DapLedgerTxHashCommand::respondToClient(const QVariant &args) ...@@ -26,9 +26,35 @@ QVariant DapLedgerTxHashCommand::respondToClient(const QVariant &args)
QJsonObject resultObj; QJsonObject resultObj;
QJsonDocument resultDoc; QJsonDocument resultDoc;
auto getErrorMessageFromData = [](const QJsonObject& resultToCheck){
const QString errsCode = "errors";
const QString msgsCode = "message";
if (resultToCheck.contains(errsCode) && resultToCheck[errsCode].isArray())
{
auto arr = resultToCheck[errsCode].toArray();
if (!arr.isEmpty() && arr[0].isObject())
{
auto msgsObj = arr[0].toObject();
if (msgsObj.contains(msgsCode) && msgsObj[msgsCode].isString())
{
return msgsObj[msgsCode].toString();
}
}
}
return QString();
};
if(errorMsg.isEmpty()) if(errorMsg.isEmpty())
{ {
resultObj.insert(RESULT_KEY, result); QString dataErrMsg = getErrorMessageFromData(result);
if (!dataErrMsg.isEmpty())
{
resultObj.insert(ERROR_KEY, dataErrMsg);
}
else
{
resultObj.insert(RESULT_KEY, result);
}
} }
else else
{ {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment