From e0992467867e4832b3333fb0cb5a638d05250bd3 Mon Sep 17 00:00:00 2001 From: "Matthias P. Braendli" Date: Tue, 12 Mar 2019 16:08:27 +0100 Subject: RC: avoid zmq RC crash on 'show' of non-existing controllable --- src/RemoteControl.cpp | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/src/RemoteControl.cpp b/src/RemoteControl.cpp index 808153a..1065456 100644 --- a/src/RemoteControl.cpp +++ b/src/RemoteControl.cpp @@ -523,16 +523,21 @@ void RemoteControllerZmq::process() } else if (msg.size() == 2 && command == "show") { std::string module((char*) msg[1].data(), msg[1].size()); - list< vector > r = rcs.get_param_list_values(module); - size_t r_size = r.size(); - for (auto ¶m_val : r) { - std::stringstream ss; - ss << param_val[0] << ": " << param_val[1] << endl; - zmq::message_t zmsg(ss.str().size()); - memcpy(zmsg.data(), ss.str().data(), ss.str().size()); - - int flag = (--r_size > 0) ? ZMQ_SNDMORE : 0; - repSocket.send(zmsg, flag); + try { + list< vector > r = rcs.get_param_list_values(module); + size_t r_size = r.size(); + for (auto ¶m_val : r) { + std::stringstream ss; + ss << param_val[0] << ": " << param_val[1] << endl; + zmq::message_t zmsg(ss.str().size()); + memcpy(zmsg.data(), ss.str().data(), ss.str().size()); + + int flag = (--r_size > 0) ? ZMQ_SNDMORE : 0; + repSocket.send(zmsg, flag); + } + } + catch (const ParameterError &err) { + send_fail_reply(repSocket, err.what()); } } else if (msg.size() == 3 && command == "get") { -- cgit v1.2.3