24#include <boost/mpi/collectives.hpp>
37 : m_comm(std::move(comm)) {}
40 if (!m_errors.empty()) {
42 std::cerr <<
"There were unhandled errors.\n";
52 m_errors.emplace_back(std::move(
message));
56 const std::string &msg,
57 const char *function,
const char *file,
59 m_errors.emplace_back(level, m_comm.rank(), msg, std::string(function),
60 std::string(file), line);
64 const char *function,
const char *file,
67 std::string(function), std::string(file), line);
71 const char *file,
const int line) {
72 warning(std::string(msg), function, file, line);
76 const char *function,
const char *file,
78 warning(mstr.str(), function, file, line);
82 const char *file,
const int line) {
84 std::string(function), std::string(file), line);
88 const char *file,
const int line) {
89 error(std::string(msg), function, file, line);
93 const char *function,
const char *file,
95 error(mstr.str(), function, file, line);
99 return boost::mpi::all_reduce(m_comm,
static_cast<int>(m_errors.size()),
104 return static_cast<int>(std::count_if(
105 m_errors.begin(), m_errors.end(),
106 [level](
const RuntimeError &e) { return e.level() >= level; }));
112 for (
auto const &e : m_errors) {
113 std::cerr << e.format() << std::endl;
119 std::vector<RuntimeError> all_errors{};
120 std::swap(all_errors, m_errors);
void clear()
Reset error messages.
void message(RuntimeError message)
void flush()
Flush error messages to standard error.
std::vector< RuntimeError > gather()
int count() const
Get the number of all flying messages on all nodes.
void error(const std::string &msg, const char *function, const char *file, int line)
void warning(const std::string &msg, const char *function, const char *file, int line)
RuntimeErrorCollector(boost::mpi::communicator comm)
void gather_buffer(std::vector< T, Allocator > &buffer, boost::mpi::communicator const &comm, int root=0)
Gather buffer with different size on each node.
ErrorLevel
The error level, warnings are only displayed to the user, errors are fatal.