Make sure that handlers always return Json::objectValue.

This commit is contained in:
Tom Ritchford
2014-12-01 15:26:59 -05:00
parent b0d47ebcc6
commit 86df482842
22 changed files with 43 additions and 32 deletions

View File

@@ -140,17 +140,9 @@ Json::Value RPCHandler::doCommand (
LoadEvent::autoptr ev = getApp().getJobQueue().getLoadEventAP(
jtGENERIC, "cmd:" + strCommand);
RPC::Context context {params, loadType, netOps_, infoSub_, role_};
Json::Value jvRaw = handler->method_(context);
// Regularize result.
if (jvRaw.isObject ())
return jvRaw;
// Probably got a string.
Json::Value jvResult (Json::objectValue);
jvResult[jss::message] = jvRaw;
return jvResult;
auto result = handler->method_(context);
assert (result.isObject());
return result;
}
catch (std::exception& e)
{