summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/rpc-server/commands/trex_rpc_cmd_general.cpp6
-rw-r--r--src/rpc-server/commands/trex_rpc_cmd_stream.cpp12
-rw-r--r--src/sim/trex_sim_stateless.cpp8
-rw-r--r--src/stateless/cp/trex_stateless_port.cpp14
4 files changed, 22 insertions, 18 deletions
diff --git a/src/rpc-server/commands/trex_rpc_cmd_general.cpp b/src/rpc-server/commands/trex_rpc_cmd_general.cpp
index 66999144..084e154a 100644
--- a/src/rpc-server/commands/trex_rpc_cmd_general.cpp
+++ b/src/rpc-server/commands/trex_rpc_cmd_general.cpp
@@ -243,7 +243,7 @@ TrexRpcCmdAcquire::_run(const Json::Value &params, Json::Value &result) {
try {
port->acquire(new_owner, session_id, force);
- } catch (const TrexRpcException &ex) {
+ } catch (const TrexException &ex) {
generate_execute_err(result, ex.what());
}
@@ -265,7 +265,7 @@ TrexRpcCmdRelease::_run(const Json::Value &params, Json::Value &result) {
try {
port->release();
- } catch (const TrexRpcException &ex) {
+ } catch (const TrexException &ex) {
generate_execute_err(result, ex.what());
}
@@ -287,7 +287,7 @@ TrexRpcCmdGetPortStats::_run(const Json::Value &params, Json::Value &result) {
try {
port->encode_stats(result["result"]);
- } catch (const TrexRpcException &ex) {
+ } catch (const TrexException &ex) {
generate_execute_err(result, ex.what());
}
diff --git a/src/rpc-server/commands/trex_rpc_cmd_stream.cpp b/src/rpc-server/commands/trex_rpc_cmd_stream.cpp
index 69e5dd18..8c07bc46 100644
--- a/src/rpc-server/commands/trex_rpc_cmd_stream.cpp
+++ b/src/rpc-server/commands/trex_rpc_cmd_stream.cpp
@@ -116,7 +116,7 @@ TrexRpcCmdAddStream::_run(const Json::Value &params, Json::Value &result) {
try {
port->add_stream(stream);
- } catch (const TrexRpcException &ex) {
+ } catch (const TrexException &ex) {
generate_execute_err(result, ex.what());
}
@@ -350,7 +350,7 @@ TrexRpcCmdRemoveStream::_run(const Json::Value &params, Json::Value &result) {
try {
port->remove_stream(stream);
- } catch (const TrexRpcException &ex) {
+ } catch (const TrexException &ex) {
generate_execute_err(result, ex.what());
}
@@ -374,7 +374,7 @@ TrexRpcCmdRemoveAllStreams::_run(const Json::Value &params, Json::Value &result)
try {
port->remove_and_delete_all_streams();
- } catch (const TrexRpcException &ex) {
+ } catch (const TrexException &ex) {
generate_execute_err(result, ex.what());
}
@@ -493,7 +493,7 @@ TrexRpcCmdStopTraffic::_run(const Json::Value &params, Json::Value &result) {
try {
port->stop_traffic();
- } catch (const TrexRpcException &ex) {
+ } catch (const TrexException &ex) {
generate_execute_err(result, ex.what());
}
@@ -550,7 +550,7 @@ TrexRpcCmdPauseTraffic::_run(const Json::Value &params, Json::Value &result) {
try {
port->pause_traffic();
- } catch (const TrexRpcException &ex) {
+ } catch (const TrexException &ex) {
generate_execute_err(result, ex.what());
}
@@ -571,7 +571,7 @@ TrexRpcCmdResumeTraffic::_run(const Json::Value &params, Json::Value &result) {
try {
port->resume_traffic();
- } catch (const TrexRpcException &ex) {
+ } catch (const TrexException &ex) {
generate_execute_err(result, ex.what());
}
diff --git a/src/sim/trex_sim_stateless.cpp b/src/sim/trex_sim_stateless.cpp
index 13f264cf..46b9916f 100644
--- a/src/sim/trex_sim_stateless.cpp
+++ b/src/sim/trex_sim_stateless.cpp
@@ -268,12 +268,16 @@ SimStateless::prepare_dataplane() {
void
SimStateless::execute_json(const std::string &json_filename) {
-
+ std::string rep;
std::ifstream test(json_filename);
std::stringstream buffer;
buffer << test.rdbuf();
- std::string rep = m_trex_stateless->get_rpc_server()->test_inject_request(buffer.str());
+ try {
+ rep = m_trex_stateless->get_rpc_server()->test_inject_request(buffer.str());
+ } catch (TrexRpcException &e) {
+ throw SimRunException(e.what());
+ }
Json::Value root;
Json::Reader reader;
diff --git a/src/stateless/cp/trex_stateless_port.cpp b/src/stateless/cp/trex_stateless_port.cpp
index d47802ec..2286ef76 100644
--- a/src/stateless/cp/trex_stateless_port.cpp
+++ b/src/stateless/cp/trex_stateless_port.cpp
@@ -114,9 +114,9 @@ TrexStatelessPort::acquire(const std::string &user, uint32_t session_id, bool fo
} else {
/* not same user or session id and not force - report error */
if (get_owner().get_name() == user) {
- throw TrexRpcException("port is already owned by another session of '" + user + "'");
+ throw TrexException("port is already owned by another session of '" + user + "'");
} else {
- throw TrexRpcException("port is already taken by '" + get_owner().get_name() + "'");
+ throw TrexException("port is already taken by '" + get_owner().get_name() + "'");
}
}
@@ -163,7 +163,7 @@ TrexStatelessPort::start_traffic(const TrexPortMultiplier &mul, double duration,
factor,
&fail_msg);
if (!rc) {
- throw TrexRpcException(fail_msg);
+ throw TrexException(fail_msg);
}
/* generate a message to all the relevant DP cores to start transmitting */
@@ -238,11 +238,11 @@ TrexStatelessPort::pause_traffic(void) {
verify_state(PORT_STATE_TX);
if (m_last_all_streams_continues == false) {
- throw TrexRpcException(" pause is supported when all streams are in continues mode ");
+ throw TrexException(" pause is supported when all streams are in continues mode ");
}
if ( m_last_duration>0.0 ) {
- throw TrexRpcException(" pause is supported when duration is not enable is start command ");
+ throw TrexException(" pause is supported when duration is not enable is start command ");
}
TrexStatelessCpToDpMsgBase *pause_msg = new TrexStatelessDpPause(m_port_id);
@@ -296,7 +296,7 @@ TrexStatelessPort::update_traffic(const TrexPortMultiplier &mul, bool force) {
case TrexPortMultiplier::OP_SUB:
factor = (m_factor - new_factor) / m_factor;
if (factor <= 0) {
- throw TrexRpcException("Update request will lower traffic to less than zero");
+ throw TrexException("Update request will lower traffic to less than zero");
}
break;
@@ -347,7 +347,7 @@ bool
TrexStatelessPort::verify_state(int state, bool should_throw) const {
if ( (state & m_port_state) == 0 ) {
if (should_throw) {
- throw TrexRpcException("command cannot be executed on current state: '" + get_state_as_string() + "'");
+ throw TrexException("command cannot be executed on current state: '" + get_state_as_string() + "'");
} else {
return false;
}