12#ifdef NF_WITH_MPI_SUPPORT
23#ifdef NF_DEBUG_MESSAGING
24#include "cpptrace/cpptrace.hpp"
51 const char*
what() const noexcept
override {
return message_.c_str(); }
60#ifdef NF_DEBUG_MESSAGING
71#define NF_ERROR_MESSAGE(message) \
72 "Error: " << message << "\nFile: " << __FILE__ << "\nLine: " << __LINE__ << "\n" \
73 << cpptrace::generate_trace().to_string() << "\n"
85#define NF_ERROR_MESSAGE(message) \
86 "Error: " << message << "\nFile: " << __FILE__ << "\nLine: " << __LINE__ << "\n"
99#ifdef NF_WITH_MPI_SUPPORT
100#define NF_ERROR_EXIT(message) \
103 std::cerr << NF_ERROR_MESSAGE(message); \
104 MPI_Abort(MPI_COMM_WORLD, 1); \
108#define NF_ERROR_EXIT(message) \
111 std::cerr << NF_ERROR_MESSAGE(message); \
127#define NF_THROW(message) \
128 throw NeoFOAM::NeoFOAMException((std::stringstream() << NF_ERROR_MESSAGE(message)).str())
142#define NF_ASSERT(condition, message) \
145 if (!(condition)) [[unlikely]] \
147 NF_ERROR_EXIT("Assertion `" #condition "` failed.\n " << message); \
165#define NF_ASSERT_THROW(condition, message) \
168 if (!(condition)) [[unlikely]] \
170 NF_THROW("Assertion `" #condition "` failed.\n " << message); \
186#define NF_DEBUG_ASSERT(condition, message) NF_ASSERT(condition, message)
199#define NF_DEBUG_ASSERT_THROW(condition, message) NF_ASSERT_THROW(condition, message)
211#define NF_DEBUG_ASSERT(condition, message) ((void)0)
224#define NF_DEBUG_ASSERT_THROW(condition, message) ((void)0)
239#define NF_ASSERT_EQUAL(a, b) NF_ASSERT(a == b, "Expected " << b << ", got " << a)
251#define NF_DEBUG_ASSERT_EQUAL(a, b) NF_DEBUG_ASSERT(a == b, "Expected " << b << ", got " << a)
266#define NF_ASSERT_EQUAL_THROW(a, b) NF_ASSERT_THROW(a == b, "Expected " << b << ", got " << a)
278#define NF_DEBUG_ASSERT_EQUAL_THROW(a, b) \
279 NF_DEBUG_ASSERT_THROW(a == b, "Expected " << b << ", got " << a)
Custom exception class for NeoFOAM.
const char * what() const noexcept override
Returns the error message associated with the exception.
NeoFOAMException(const std::string &message)
Constructs a NeoFOAMException object with the given error message.