Encoder/Exporter: Handle exceptions inside destructors

parent bfd5296a
Pipeline #67127 passed with stage
in 3 minutes and 3 seconds
......@@ -13,6 +13,7 @@
#include <string.h>
#include <stdlib.h>
#include <istream>
#include <iostream>
#include <sys/socket.h>
#include "format_specification.h"
......@@ -61,8 +62,13 @@ namespace CDNS {
* if any output is currently open
*/
~CdnsExporter() {
if (m_blocks_written > 0)
m_encoder.write_break();
try {
if (m_blocks_written > 0)
m_encoder.write_break();
}
catch (std::exception& e) {
std::cerr << "Couldn't write end break to output: " << e.what() << std::endl;
}
}
/** Delete [move] copy constructors and assignment operators */
......
......@@ -67,7 +67,13 @@ namespace CDNS {
* @brief Destroy the CdnsEncoder object and properly close the C-DNS output
*/
~CdnsEncoder() {
flush_buffer();
try {
flush_buffer();
}
catch (std::exception& e) {
std::cerr << e.what() << std::endl;
}
if(m_cos)
delete m_cos;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment