Log common exceptions before asserting (#1278)

This commit is contained in:
cryptocode 2018-10-09 17:11:02 +02:00 committed by Roy Keene
commit f7480aad6e
2 changed files with 18 additions and 0 deletions

View file

@ -6,6 +6,8 @@
#include <boost/property_tree/ptree.hpp>
#include <cstdint>
#define FATAL_LOG_PREFIX "FATAL ERROR: "
namespace rai
{
class logging

View file

@ -51,8 +51,24 @@ on (true)
{
process_packets ();
}
catch (boost::system::error_code & ec)
{
BOOST_LOG (this->node.log) << FATAL_LOG_PREFIX << ec.message ();
release_assert (false);
}
catch (std::error_code & ec)
{
BOOST_LOG (this->node.log) << FATAL_LOG_PREFIX << ec.message ();
release_assert (false);
}
catch (std::runtime_error & err)
{
BOOST_LOG (this->node.log) << FATAL_LOG_PREFIX << err.what ();
release_assert (false);
}
catch (...)
{
BOOST_LOG (this->node.log) << FATAL_LOG_PREFIX << "Unknown exception";
release_assert (false);
}
if (this->node.config.logging.network_packet_logging ())