本文整理汇总了C++中ErrorCode::fill方法的典型用法代码示例。如果您正苦于以下问题:C++ ErrorCode::fill方法的具体用法?C++ ErrorCode::fill怎么用?C++ ErrorCode::fill使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ErrorCode
的用法示例。
在下文中一共展示了ErrorCode::fill方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: parseBatchUpdate
/* ****************************************************************************
*
* parseBatchUpdate -
*/
std::string parseBatchUpdate(ConnectionInfo* ciP, BatchUpdate* burP)
{
Document document;
document.Parse(ciP->payload);
if (document.HasParseError())
{
ErrorCode ec;
alarmMgr.badInput(clientIp, "JSON Parse Error");
ec.fill(ERROR_STRING_PARSERROR, "Errors found in incoming JSON buffer");
ciP->httpStatusCode = SccBadRequest;
return ec.toJson(true);
}
if (!document.IsObject())
{
ErrorCode ec;
alarmMgr.badInput(clientIp, "JSON Parse Error");
ec.fill("BadRequest", "JSON Parse Error");
ciP->httpStatusCode = SccBadRequest;
return ec.toJson(true);
}
else if (document.ObjectEmpty())
{
ErrorCode ec;
alarmMgr.badInput(clientIp, "Empty JSON payload");
ec.fill("BadRequest", "empty payload");
ciP->httpStatusCode = SccBadRequest;
return ec.toJson(true);
}
else if (!document.HasMember("entities"))
{
ErrorCode ec;
std::string details = "Invalid JSON payload, mandatory field /entities/ not found";
alarmMgr.badInput(clientIp, details);
ec.fill("BadRequest", details);
ciP->httpStatusCode = SccBadRequest;
return ec.toJson(true);
}
else if (!document.HasMember("actionType"))
{
ErrorCode ec;
std::string details = "Invalid JSON payload, mandatory field /actionType/ not found";
alarmMgr.badInput(clientIp, details);
ec.fill("BadRequest", details);
ciP->httpStatusCode = SccBadRequest;
return ec.toJson(true);
}
for (Value::ConstMemberIterator iter = document.MemberBegin(); iter != document.MemberEnd(); ++iter)
{
std::string name = iter->name.GetString();
std::string type = jsonParseTypeNames[iter->value.GetType()];
if (name == "entities")
{
std::string r = parseEntityVector(ciP, iter, &burP->entities, true); // param 4: attributes are allowed in payload
if (r != "OK")
{
ErrorCode ec("BadRequest", r);
alarmMgr.badInput(clientIp, r);
ciP->httpStatusCode = SccBadRequest;
return ec.toJson(true);
}
}
else if (name == "actionType")
{
burP->updateActionType.set(iter->value.GetString());
}
else
{
std::string description = std::string("Unrecognized field in JSON payload: /") + name + "/";
ErrorCode ec("BadRequest", description);
alarmMgr.badInput(clientIp, description);
ciP->httpStatusCode = SccBadRequest;
return ec.toJson(true);
}
}
return "OK";
}
示例2: parseBatchQuery
/* ****************************************************************************
*
* parseBatchQuery -
*/
std::string parseBatchQuery(ConnectionInfo* ciP, BatchQuery* bqrP)
{
Document document;
document.Parse(ciP->payload);
if (document.HasParseError())
{
ErrorCode ec;
alarmMgr.badInput(clientIp, "JSON Parse Error");
ec.fill(ERROR_STRING_PARSERROR, "Errors found in incoming JSON buffer");
ciP->httpStatusCode = SccBadRequest;
return ec.toJson(true);
}
if (!document.IsObject())
{
ErrorCode ec;
alarmMgr.badInput(clientIp, "JSON Parse Error");
ec.fill("BadRequest", "JSON Parse Error");
ciP->httpStatusCode = SccBadRequest;
return ec.toJson(true);
}
else if (document.ObjectEmpty())
{
ErrorCode ec;
alarmMgr.badInput(clientIp, "Empty JSON payload");
ec.fill("BadRequest", "empty payload");
ciP->httpStatusCode = SccBadRequest;
return ec.toJson(true);
}
else if (!document.HasMember("entities") && !document.HasMember("attributes") && !document.HasMember("scopes"))
{
ErrorCode ec;
alarmMgr.badInput(clientIp, "Invalid JSON payload, no relevant fields found");
ec.fill("BadRequest", "Invalid JSON payload, no relevant fields found");
ciP->httpStatusCode = SccBadRequest;
return ec.toJson(true);
}
for (Value::ConstMemberIterator iter = document.MemberBegin(); iter != document.MemberEnd(); ++iter)
{
std::string name = iter->name.GetString();
std::string type = jsonParseTypeNames[iter->value.GetType()];
if (name == "entities")
{
std::string r = parseEntityVector(ciP, iter, &bqrP->entities, false); // param 4: attributes are NOT allowed in payload
if (r != "OK")
{
ErrorCode ec("BadRequest", r);
alarmMgr.badInput(clientIp, r);
ciP->httpStatusCode = SccBadRequest;
return ec.toJson(true);
}
}
else if (name == "attributes")
{
std::string r = parseAttributeList(ciP, iter, &bqrP->attributeV);
if (r != "OK")
{
ErrorCode ec("BadRequest", r);
alarmMgr.badInput(clientIp, r);
ciP->httpStatusCode = SccBadRequest;
return ec.toJson(true);
}
}
else if (name == "scopes")
{
std::string r = parseScopeVector(ciP, iter, &bqrP->scopeV);
if (r != "OK")
{
ErrorCode ec("BadRequest", r);
alarmMgr.badInput(clientIp, r);
ciP->httpStatusCode = SccBadRequest;
return ec.toJson(true);
}
}
else
{
std::string description = std::string("Unrecognizedfield in JSON payload: /") + name + "/";
ErrorCode ec("BadRequest", description);
//.........这里部分代码省略.........