WS: Report back sterilization errors.

This commit is contained in:
Arthur Britto
2012-10-31 19:54:34 -07:00
parent 811eb8cf7c
commit 127bceab5a
2 changed files with 20 additions and 5 deletions

View File

@@ -88,17 +88,26 @@ Transaction::pointer NetworkOPs::submitTransaction(const Transaction::pointer& t
tpTrans->getSTransaction()->add(s);
Transaction::pointer tpTransNew = Transaction::sharedTransaction(s.getData(), true);
assert(tpTransNew);
if(!tpTransNew->getSTransaction()->isEquivalent(*tpTrans->getSTransaction()))
if (!tpTransNew)
{
// Could not construct transaction.
nothing();
}
else if (tpTransNew->getSTransaction()->isEquivalent(*tpTrans->getSTransaction()))
{
(void) NetworkOPs::processTransaction(tpTransNew);
}
else
{
cLog(lsFATAL) << "Transaction reconstruction failure";
cLog(lsFATAL) << tpTransNew->getSTransaction()->getJson(0);
cLog(lsFATAL) << tpTrans->getSTransaction()->getJson(0);
assert(false);
}
(void) NetworkOPs::processTransaction(tpTransNew);
assert(false);
tpTransNew = Transaction::pointer();
}
return tpTransNew;
}

View File

@@ -1072,6 +1072,12 @@ void WSConnection::doSubmit(Json::Value& jvResult, const Json::Value& jvRequest)
try
{
tpTrans = mNetwork.submitTransaction(tpTrans);
if (!tpTrans) {
jvResult["error"] = "invalidTransaction";
jvResult["error_exception"] = "Unable to sterilize transaction.";
return;
}
}
catch (std::exception& e)
{