Skip to content

Commit

Permalink
Log intercepted I/O exceptions in verbose mode
Browse files Browse the repository at this point in the history
  • Loading branch information
franzpoeschel committed Dec 18, 2023
1 parent 55af0db commit a62b643
Showing 1 changed file with 36 additions and 8 deletions.
44 changes: 36 additions & 8 deletions src/IO/AbstractIOHandlerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -366,16 +366,44 @@ std::future<void> AbstractIOHandlerImpl::flush()
}
catch (...)
{
std::cerr << "[AbstractIOHandlerImpl] IO Task "
<< internal::operationAsString(i.operation)
<< " failed with exception. Clearing IO queue and "
"passing on the exception."
<< std::endl;
while (!m_handler->m_work.empty())
auto base_handler = [&i, this]() {
std::cerr << "[AbstractIOHandlerImpl] IO Task "
<< internal::operationAsString(i.operation)
<< " failed with exception. Clearing IO queue and "
"passing on the exception."
<< std::endl;
while (!m_handler->m_work.empty())
{
m_handler->m_work.pop();
}
};

if (m_verboseIOTasks)
{
try
{
// Throw again so we can distinguish between std::exception
// and other exception types.
throw;
}
catch (std::exception const &e)
{
base_handler();
std::cerr << "Original exception: " << e.what()
<< std::endl;
throw;
}
catch (...)
{
base_handler();
throw;
}
}
else
{
m_handler->m_work.pop();
base_handler();
throw;
}
throw;
}
(*m_handler).m_work.pop();
}
Expand Down

0 comments on commit a62b643

Please sign in to comment.