using only sls exceptions

This commit is contained in:
Erik Frojdh 2019-03-14 17:09:44 +01:00
parent bad44f5bf4
commit 9f724f0c0d
8 changed files with 29 additions and 16 deletions

View File

@ -385,7 +385,7 @@ std::string multiSlsDetector::exec(const char *cmd) {
std::string result = "";
FILE *pipe = popen(cmd, "r");
if (!pipe) {
throw std::exception();
throw RuntimeError("Could not open pipe");
}
try {
while (!feof(pipe)) {

View File

@ -14,6 +14,7 @@
#include "HDF5File.h"
#endif
#include "DataStreamer.h"
#include "sls_detector_exceptions.h"
#include <iostream>
#include <errno.h>
@ -56,7 +57,7 @@ DataProcessor::DataProcessor(int ind, detectorType dtype, Fifo* f,
currentFrameIndex(0)
{
if(ThreadObject::CreateThread() == FAIL)
throw std::exception();
throw sls::RuntimeError("Could not create processing thread");
FILE_LOG(logDEBUG) << "DataProcessor " << ind << " created";

View File

@ -8,6 +8,7 @@
#include "GeneralData.h"
#include "Fifo.h"
#include "ZmqSocket.h"
#include "sls_detector_exceptions.h"
#include <iostream>
#include <errno.h>
@ -35,7 +36,7 @@ DataStreamer::DataStreamer(int ind, Fifo* f, uint32_t* dr, std::vector<ROI>* r,
completeBuffer(nullptr)
{
if(ThreadObject::CreateThread() == FAIL)
throw std::exception();
throw sls::RuntimeError("Could not create streaming thread");
FILE_LOG(logDEBUG) << "DataStreamer " << ind << " created";

View File

@ -6,6 +6,7 @@
***********************************************/
#include "Fifo.h"
#include "sls_detector_exceptions.h"
#include <iostream>
#include <cstdlib>
@ -23,7 +24,7 @@ Fifo::Fifo(int ind, uint32_t fifoItemSize, uint32_t depth):
status_fifoFree(depth){
FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called";
if(CreateFifos(fifoItemSize) == FAIL)
throw std::exception();
throw sls::RuntimeError("Could not create FIFO");
}

View File

@ -11,6 +11,7 @@
#include "Fifo.h"
#include "genericSocket.h"
#include "container_utils.h" // For sls::make_unique<>
#include "sls_detector_exceptions.h"
#include <iostream>
#include <errno.h>
@ -57,7 +58,7 @@ Listener::Listener(int ind, detectorType dtype, Fifo* f, runStatus* s,
oddStartingPacket(true)
{
if(ThreadObject::CreateThread() == FAIL)
throw std::exception();
throw sls::RuntimeError("Could not create listener thread");
FILE_LOG(logDEBUG) << "Listener " << ind << " created";
}

View File

@ -15,6 +15,7 @@
#include "slsReceiver.h"
#include "slsReceiverTCPIPInterface.h"
#include "sls_detector_exceptions.h"
#include "gitInfoReceiver.h"
#include "logger.h"
@ -60,7 +61,7 @@ slsReceiver::slsReceiver(int argc, char *argv[]):
tempval = GITREV;
tempval = (tempval <<32) | GITDATE;
std::cout << "SLS Receiver " << GITBRANCH << " (0x" << std::hex << tempval << ")" << std::endl;
throw std::exception();
throw sls::RuntimeError();
case 'h':
default:
@ -73,7 +74,7 @@ slsReceiver::slsReceiver(int argc, char *argv[]):
+ "\t receivers\n\n";
FILE_LOG(logINFO) << help_message << std::endl;
throw std::exception();
throw sls::RuntimeError();
}
}

View File

@ -8,7 +8,7 @@
*/
#include "ansi.h"
#include "sls_detector_exceptions.h"
#include <iostream>
#include <zmq.h>
@ -27,6 +27,8 @@ using namespace rapidjson;
// #define ZMQ_DETAIL
#define ROIVERBOSITY
class ZmqSocket {
public:
@ -54,7 +56,7 @@ public:
struct addrinfo *result;
if ((ConvertHostnameToInternetAddress(hostname_or_ip, &result)) ||
(ConvertInternetAddresstoIpString(result, ip, MAX_STR_LENGTH)))
throw std::exception();
throw sls::ZmqSocketError("Could convert IP to string");
// construct address
sprintf (sockfd.serverAddress, "tcp://%s:%d", ip, portno);
@ -65,14 +67,14 @@ public:
// create context
sockfd.contextDescriptor = zmq_ctx_new();
if (sockfd.contextDescriptor == 0)
throw std::exception();
throw sls::ZmqSocketError("Could not create contextDescriptor");
// create publisher
sockfd.socketDescriptor = zmq_socket (sockfd.contextDescriptor, ZMQ_SUB);
if (sockfd.socketDescriptor == 0) {
PrintError ();
Close ();
throw std::exception();
throw sls::ZmqSocketError("Could not create socket");
}
//Socket Options provided above
@ -80,7 +82,7 @@ public:
if ( zmq_setsockopt(sockfd.socketDescriptor, ZMQ_SUBSCRIBE, "", 0)) {
PrintError ();
Close();
throw std::exception();
throw sls::ZmqSocketError("Could set socket opt");
}
//ZMQ_LINGER default is already -1 means no messages discarded. use this options if optimizing required
//ZMQ_SNDHWM default is 0 means no limit. use this to optimize if optimizing required
@ -89,7 +91,7 @@ public:
if (zmq_setsockopt(sockfd.socketDescriptor, ZMQ_LINGER, &value,sizeof(value))) {
PrintError ();
Close();
throw std::exception();
throw sls::ZmqSocketError("Could not set ZMQ_LINGER");
}
};
@ -110,13 +112,13 @@ public:
// create context
sockfd.contextDescriptor = zmq_ctx_new();
if (sockfd.contextDescriptor == 0)
throw std::exception();
throw sls::ZmqSocketError("Could not create contextDescriptor");
// create publisher
sockfd.socketDescriptor = zmq_socket (sockfd.contextDescriptor, ZMQ_PUB);
if (sockfd.socketDescriptor == 0) {
PrintError ();
Close ();
throw std::exception();
throw sls::ZmqSocketError("Could not create socket");
}
//Socket Options provided above
@ -130,7 +132,7 @@ public:
if (zmq_bind (sockfd.socketDescriptor, sockfd.serverAddress) < 0) {
PrintError ();
Close ();
throw std::exception();
throw sls::ZmqSocketError("Could not bind socket");
}
//sleep for a few milliseconds to allow a slow-joiner

View File

@ -30,6 +30,12 @@ public:
};
struct ZmqSocketError : public RuntimeError {
public:
ZmqSocketError(std::string msg):RuntimeError(msg) {}
};
}