diff --git a/utils/filter_streams.cc b/utils/filter_streams.cc index 71c2fdf..e767507 100644 --- a/utils/filter_streams.cc +++ b/utils/filter_streams.cc @@ -32,6 +32,7 @@ #include #include "jml/arch/exception.h" #include "jml/arch/format.h" +#include "jml/arch/threads.h" #include "string_functions.h" #include #include @@ -119,8 +120,9 @@ filter_ostream:: try { close(); } - catch (...) { - cerr << "~filter_ostream: ignored exception\n"; + catch (const std::exception & exc) { + cerr << ("~filter_ostream: ignored exception: " + + string(exc.what()) + "\n"); } } @@ -472,9 +474,11 @@ void filter_ostream:: close() { + bool wasClosed(true); // closed when "close" is called if (stream) { boost::iostreams::flush(*stream); boost::iostreams::close(*stream); + wasClosed = false; } exceptions(ios::goodbit); rdbuf(0); @@ -482,6 +486,11 @@ close() sink.reset(); options.clear(); if (hasDeferredFailure()) { + if (wasClosed) { + cerr << (to_string(getpid()) + "/" + to_string(gettid()) + + ": filter_ostream: a deferred failure has been reported" + " for a closed stream\n"); + } clearDeferredFailure(); exceptions(ios::badbit | ios::failbit); setstate(ios::badbit); @@ -533,8 +542,9 @@ filter_istream:: try { close(); } - catch (...) { - cerr << "~filter_istream: ignored exception\n"; + catch (const std::exception & exc) { + cerr << ("~filter_istream: ignored exception: " + + string(exc.what()) + "\n"); } }