27 #ifndef LBANN_UTILS_EXCEPTION_HPP_INCLUDED 28 #define LBANN_UTILS_EXCEPTION_HPP_INCLUDED 37 #define LBANN_ERROR(...) \ 39 const int rank_LBANN_ERROR = lbann::get_rank_in_world(); \ 40 throw ::lbann::exception(::lbann::build_string( \ 42 (rank_LBANN_ERROR >= 0 ? " on rank " + std::to_string(rank_LBANN_ERROR) \ 53 #define LBANN_WARNING(...) \ 55 const int rank_LBANN_WARNING = lbann::get_rank_in_world(); \ 56 std::cerr << lbann::build_string( \ 58 (rank_LBANN_WARNING >= 0 \ 59 ? " on rank " + std::to_string(rank_LBANN_WARNING) \ 70 #define LBANN_WARNING_WORLD_ROOT(...) \ 72 if (lbann::get_rank_in_world() == 0) { \ 73 LBANN_WARNING(__VA_ARGS__); \ 78 #define LBANN_MSG(...) \ 80 const int rank_LBANN_MSG = lbann::get_rank_in_world(); \ 81 if (rank_LBANN_MSG == 0) { \ 82 std::cout << lbann::build_string( \ 84 (rank_LBANN_MSG >= 0 \ 85 ? " on rank " + std::to_string(rank_LBANN_MSG) \ 97 #define LBANN_ASSERT(cond) \ 99 LBANN_ERROR("The assertion " #cond " failed.") 102 #define LBANN_ASSERT_DEBUG(cond) LBANN_ASSERT(cond) 104 #define LBANN_ASSERT_DEBUG(cond) 107 #define LBANN_ASSERT_WARNING(cond) \ 109 LBANN_WARNING("The assertion " #cond " failed.") 136 char const*
what()
const noexcept
override;
156 template <
typename... Args>
159 std::ostringstream oss;
160 int dummy[] = {(oss << args, 0)...};
167 #endif // LBANN_UTILS_EXCEPTION_HPP_INCLUDED The base exception for LBANN errors.
char const * what() const noexcept override
std::string build_string(Args &&... args)
Build a string from the arguments.
void print_report(std::ostream &os=std::cerr) const
Print the what() string to the stream.
exception()
Default constructor.