summaryrefslogtreecommitdiffstats
path: root/src/rpc-server/trex_rpc_cmd.cpp
diff options
context:
space:
mode:
authorimarom <imarom@cisco.com>2015-08-31 17:26:08 +0300
committerimarom <imarom@cisco.com>2015-08-31 17:26:08 +0300
commit40461a9752437ee541d797f76d2fba77cad9d0e2 (patch)
tree4ff731920ccd25a0fa5080a4553f0300d49db7a8 /src/rpc-server/trex_rpc_cmd.cpp
parent499b4d6221c023d656663fe441bbf5d194886efb (diff)
...draft...
Diffstat (limited to 'src/rpc-server/trex_rpc_cmd.cpp')
-rw-r--r--src/rpc-server/trex_rpc_cmd.cpp17
1 files changed, 12 insertions, 5 deletions
diff --git a/src/rpc-server/trex_rpc_cmd.cpp b/src/rpc-server/trex_rpc_cmd.cpp
index 1ba36e32..6988cba7 100644
--- a/src/rpc-server/trex_rpc_cmd.cpp
+++ b/src/rpc-server/trex_rpc_cmd.cpp
@@ -26,6 +26,7 @@ TrexRpcCommand::run(const Json::Value &params, Json::Value &result) {
/* the internal run can throw a parser error / other error */
try {
+ check_param_count(params, m_param_count, result);
rc = _run(params, result);
} catch (TrexRpcCommandException &e) {
return e.get_rc();
@@ -40,7 +41,7 @@ TrexRpcCommand::check_param_count(const Json::Value &params, int expected, Json:
if (params.size() != expected) {
std::stringstream ss;
ss << "method expects '" << expected << "' paramteres, '" << params.size() << "' provided";
- generate_err(result, ss.str());
+ generate_parse_err(result, ss.str());
}
}
@@ -177,7 +178,7 @@ TrexRpcCommand::check_field_type_common(const Json::Value &field, const std::str
/* first check if field exists */
if (field == Json::Value::null) {
ss << "field '" << name << "' is missing";
- generate_err(result, ss.str());
+ generate_parse_err(result, ss.str());
}
bool rc = true;
@@ -232,15 +233,15 @@ TrexRpcCommand::check_field_type_common(const Json::Value &field, const std::str
}
if (!rc) {
ss << "error at offset: " << field.getOffsetStart() << " - '" << name << "' is '" << json_type_to_name(field) << "', expecting '" << type_to_str(type) << "'";
- generate_err(result, ss.str());
+ generate_parse_err(result, ss.str());
}
}
void
-TrexRpcCommand::generate_err(Json::Value &result, const std::string &msg) {
+TrexRpcCommand::generate_parse_err(Json::Value &result, const std::string &msg) {
result["specific_err"] = msg;
- throw (TrexRpcCommandException(TREX_RPC_CMD_PARAM_PARSE_ERR));
+ throw (TrexRpcCommandException(TREX_RPC_CMD_PARSE_ERR));
}
void
@@ -249,3 +250,9 @@ TrexRpcCommand::generate_internal_err(Json::Value &result, const std::string &ms
throw (TrexRpcCommandException(TREX_RPC_CMD_INTERNAL_ERR));
}
+void
+TrexRpcCommand::generate_execute_err(Json::Value &result, const std::string &msg) {
+ result["specific_err"] = msg;
+ throw (TrexRpcCommandException(TREX_RPC_CMD_EXECUTE_ERR));
+}
+