exception messages (#656)

* fix exception messages for more printout about sockets or more detail
This commit is contained in:
Dhanya Thattil
2023-02-13 11:22:05 +01:00
committed by GitHub
parent fc42720208
commit 18136fed9d
5 changed files with 253 additions and 240 deletions

View File

@ -78,11 +78,12 @@ void Implementation::SetupFifoStructure() {
try {
fifo.push_back(
sls::make_unique<Fifo>(i, datasize, generalData->fifoDepth));
} catch (...) {
} catch (const std::exception &e) {
fifo.clear();
generalData->fifoDepth = 0;
throw RuntimeError("Could not allocate memory for fifo structure " +
std::to_string(i) + ". FifoDepth is now 0.");
std::ostringstream oss;
oss << e.what() << ". Fifo depth is now 0";
throw RuntimeError(oss.str());
}
// set the listener & dataprocessor threads to point to the right fifo
if (listener.size())
@ -165,12 +166,10 @@ void Implementation::setDetectorType(const detectorType d) {
SetupListener(i);
dataProcessor.push_back(sls::make_unique<DataProcessor>(i));
SetupDataProcessor(i);
} catch (...) {
} catch (const std::exception &e) {
listener.clear();
dataProcessor.clear();
throw RuntimeError(
"Could not create listener/dataprocessor threads (index:" +
std::to_string(i) + ")");
throw;
}
}
@ -668,8 +667,9 @@ void Implementation::startReceiver() {
startAcquisitionCallBack(filePath, fileName, fileIndex, imageSize,
pStartAcquisition);
} catch (const std::exception &e) {
throw RuntimeError("Start Acquisition Callback Error: " +
std::string(e.what()));
std::ostringstream oss;
oss << "Start Acquisition Callback Error: " << e.what();
throw RuntimeError(oss.str());
}
if (rawDataReadyCallBack != nullptr) {
LOG(logINFO) << "Data Write has been defined externally";
@ -784,8 +784,9 @@ void Implementation::stopReceiver() {
status = IDLE;
LOG(logINFO) << "Receiver Stopped";
LOG(logINFO) << "Status: " << ToString(status);
throw RuntimeError("Acquisition Finished Callback Error: " +
std::string(e.what()));
std::ostringstream oss;
oss << "Acquisition Finished Callback Error: " << e.what();
throw RuntimeError(oss.str());
}
}
}
@ -866,7 +867,7 @@ void Implementation::CreateUDPSockets() {
}
} catch (const RuntimeError &e) {
shutDownUDPSockets();
throw RuntimeError("Could not create UDP Socket(s).");
throw;
}
LOG(logDEBUG) << "UDP socket(s) created successfully.";
}
@ -886,7 +887,9 @@ void Implementation::SetupWriter() {
shutDownUDPSockets();
for (const auto &it : dataProcessor)
it->CloseFiles();
throw RuntimeError("Could not create first data file.");
std::ostringstream oss;
oss << "Could not set up writer: " << e.what();
throw RuntimeError(oss.str());
}
}
@ -975,10 +978,9 @@ void Implementation::StartMasterWriter() {
}
}
#endif
} catch (std::exception &e) {
} catch (const std::exception &e) {
// ignore it and just print it
LOG(logWARNING) << "Caught exception when handling virtual hdf5 file ["
<< e.what() << "]";
LOG(logWARNING) << "Error creating master/virtualfiles: " << e.what();
}
}
@ -1039,12 +1041,10 @@ void Implementation::setNumberofUDPInterfaces(const int n) {
SetupListener(i);
dataProcessor.push_back(sls::make_unique<DataProcessor>(i));
SetupDataProcessor(i);
} catch (...) {
} catch (const std::exception &e) {
listener.clear();
dataProcessor.clear();
throw RuntimeError(
"Could not create listener/dataprocessor threads (index:" +
std::to_string(i) + ")");
throw;
}
// streamer threads
@ -1052,16 +1052,14 @@ void Implementation::setNumberofUDPInterfaces(const int n) {
try {
dataStreamer.push_back(sls::make_unique<DataStreamer>(i));
SetupDataStreamer(i);
} catch (...) {
} catch (const std::exception &e) {
if (dataStreamEnable) {
dataStreamer.clear();
dataStreamEnable = false;
for (const auto &it : dataProcessor)
it->SetDataStreamEnable(dataStreamEnable);
}
throw RuntimeError(
"Could not create datastreamer threads (index:" +
std::to_string(i) + ")");
throw;
}
}
}
@ -1172,12 +1170,12 @@ void Implementation::setDataStreamEnable(const bool enable) {
try {
dataStreamer.push_back(sls::make_unique<DataStreamer>(i));
SetupDataStreamer(i);
} catch (...) {
} catch (const std::exception &e) {
dataStreamer.clear();
dataStreamEnable = false;
for (const auto &it : dataProcessor)
it->SetDataStreamEnable(dataStreamEnable);
throw RuntimeError("Could not set data stream enable.");
throw;
}
}
SetThreadPriorities();