diff --git a/detector_control/DectrisSimplonClient.cpp b/detector_control/DectrisSimplonClient.cpp index 552513e5..90ea7e39 100644 --- a/detector_control/DectrisSimplonClient.cpp +++ b/detector_control/DectrisSimplonClient.cpp @@ -54,10 +54,12 @@ void DectrisSimplonClient::SendDetectorCommand(SimplonDetectorCommand cmd) { auto res = cli_cmd.Post(addr); if (!res || res->status != httplib::StatusCode::OK_200) { - std::string err_msg = "Command failed " + key + "; HTTP " + std::to_string(res->status); - if (res && !res->body.empty()) - err_msg += "; " + res->body; - + std::string err_msg = "Command failed " + key; + if (res) { + err_msg += "; HTTP" + std::to_string(res->status); + if (!res->body.empty()) + err_msg += "; " + res->body; + } throw JFJochException(JFJochExceptionCategory::InputParameterInvalid, err_msg); } } @@ -76,10 +78,12 @@ void DectrisSimplonClient::SetConfig(SimplonModule element, const std::string &k auto res = cli_cmd.Post(addr, j.dump(), "application/json"); if (!res || res->status != httplib::StatusCode::OK_200) { - std::string err_msg = "Configure failed " + key + "; HTTP " + std::to_string(res->status); - if (res && !res->body.empty()) - err_msg += "; " + res->body; - + std::string err_msg = "Configure failed " + key; + if (res) { + err_msg += "; HTTP" + std::to_string(res->status); + if (!res->body.empty()) + err_msg += "; " + res->body; + } throw JFJochException(JFJochExceptionCategory::InputParameterInvalid, err_msg); } }