mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-03 01:15:53 +00:00
Improve error reporting for account not found.
This commit is contained in:
@@ -186,18 +186,22 @@ AccountState::pointer Ledger::getAccountState(const RippleAddress& accountID)
|
|||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
// std::cerr << "Ledger:getAccountState(" << accountID.humanAccountID() << ")" << std::endl;
|
// std::cerr << "Ledger:getAccountState(" << accountID.humanAccountID() << ")" << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
SHAMapItem::pointer item = mAccountStateMap->peekItem(Ledger::getAccountRootIndex(accountID));
|
SHAMapItem::pointer item = mAccountStateMap->peekItem(Ledger::getAccountRootIndex(accountID));
|
||||||
if (!item)
|
if (!item)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG
|
cLog(lsDEBUG) << boost::str(boost::format("Ledger:getAccountState: not found: %s: %s")
|
||||||
// std::cerr << " notfound" << std::endl;
|
% accountID.humanAccountID()
|
||||||
#endif
|
% Ledger::getAccountRootIndex(accountID).GetHex());
|
||||||
|
|
||||||
return AccountState::pointer();
|
return AccountState::pointer();
|
||||||
}
|
}
|
||||||
|
|
||||||
SerializedLedgerEntry::pointer sle =
|
SerializedLedgerEntry::pointer sle =
|
||||||
boost::make_shared<SerializedLedgerEntry>(item->peekSerializer(), item->getTag());
|
boost::make_shared<SerializedLedgerEntry>(item->peekSerializer(), item->getTag());
|
||||||
if (sle->getType() != ltACCOUNT_ROOT)
|
if (sle->getType() != ltACCOUNT_ROOT)
|
||||||
return AccountState::pointer();
|
return AccountState::pointer();
|
||||||
|
|
||||||
return boost::make_shared<AccountState>(sle,accountID);
|
return boost::make_shared<AccountState>(sle,accountID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -55,7 +55,8 @@ Json::Value rpcError(int iError, Json::Value jvResult)
|
|||||||
{ rpcPUBLIC_MALFORMED, "publicMalformed", "Public key is malformed." },
|
{ rpcPUBLIC_MALFORMED, "publicMalformed", "Public key is malformed." },
|
||||||
{ rpcQUALITY_MALFORMED, "qualityMalformed", "Quality malformed." },
|
{ rpcQUALITY_MALFORMED, "qualityMalformed", "Quality malformed." },
|
||||||
{ rpcSRC_ACT_MALFORMED, "srcActMalformed", "Source account is malformed." },
|
{ rpcSRC_ACT_MALFORMED, "srcActMalformed", "Source account is malformed." },
|
||||||
{ rpcSRC_ACT_MISSING, "srcActMissing", "Source account does not exist." },
|
{ rpcSRC_ACT_MISSING, "srcActMissing", "Source account not provided." },
|
||||||
|
{ rpcSRC_ACT_NOT_FOUND, "srcActNotFound", "Source amount not found." },
|
||||||
{ rpcSRC_AMT_MALFORMED, "srcAmtMalformed", "Source amount/currency/issuer is malformed." },
|
{ rpcSRC_AMT_MALFORMED, "srcAmtMalformed", "Source amount/currency/issuer is malformed." },
|
||||||
{ rpcSRC_UNCLAIMED, "srcUnclaimed", "Source account is not claimed." },
|
{ rpcSRC_UNCLAIMED, "srcUnclaimed", "Source account is not claimed." },
|
||||||
{ rpcTXN_NOT_FOUND, "txnNotFound", "Transaction not found." },
|
{ rpcTXN_NOT_FOUND, "txnNotFound", "Transaction not found." },
|
||||||
|
|||||||
@@ -60,6 +60,7 @@ enum {
|
|||||||
rpcPUBLIC_MALFORMED,
|
rpcPUBLIC_MALFORMED,
|
||||||
rpcSRC_ACT_MALFORMED,
|
rpcSRC_ACT_MALFORMED,
|
||||||
rpcSRC_ACT_MISSING,
|
rpcSRC_ACT_MISSING,
|
||||||
|
rpcSRC_ACT_NOT_FOUND,
|
||||||
rpcSRC_AMT_MALFORMED,
|
rpcSRC_AMT_MALFORMED,
|
||||||
|
|
||||||
// Internal error (should never happen)
|
// Internal error (should never happen)
|
||||||
|
|||||||
@@ -932,7 +932,13 @@ Json::Value RPCHandler::doSubmit(Json::Value jvRequest)
|
|||||||
}
|
}
|
||||||
|
|
||||||
AccountState::pointer asSrc = mNetOps->getAccountState(mNetOps->getCurrentLedger(), raSrcAddressID);
|
AccountState::pointer asSrc = mNetOps->getAccountState(mNetOps->getCurrentLedger(), raSrcAddressID);
|
||||||
if (!asSrc) return rpcError(rpcSRC_ACT_MALFORMED);
|
if (!asSrc)
|
||||||
|
{
|
||||||
|
cLog(lsDEBUG) << boost::str(boost::format("doSubmit: Failed to find source account in current ledger: %s")
|
||||||
|
% raSrcAddressID.humanAccountID());
|
||||||
|
|
||||||
|
return rpcError(rpcSRC_ACT_NOT_FOUND);
|
||||||
|
}
|
||||||
|
|
||||||
if ("Payment" == txJSON["TransactionType"].asString())
|
if ("Payment" == txJSON["TransactionType"].asString())
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user