14#ifdef NF_WITH_MPI_SUPPORT
25#ifdef NF_DEBUG_MESSAGING
26#include "cpptrace/cpptrace.hpp"
47 explicit NeoNException(
const std::string& message) : message_(message) {}
53 const char*
what() const noexcept
override {
return message_.c_str(); }
62#ifdef NF_DEBUG_MESSAGING
73#define NF_ERROR_MESSAGE(message) \
74 "Error: " << message << "\nFile: " << __FILE__ << "\nLine: " << __LINE__ << "\n" \
75 << cpptrace::generate_trace().to_string() << "\n"
87#define NF_ERROR_MESSAGE(message) \
88 "Error: " << message << "\nFile: " << __FILE__ << "\nLine: " << __LINE__ << "\n"
101#ifdef NF_WITH_MPI_SUPPORT
102#define NF_ERROR_EXIT(message) \
105 std::cerr << NF_ERROR_MESSAGE(message); \
106 MPI_Abort(MPI_COMM_WORLD, 1); \
110#define NF_ERROR_EXIT(message) \
113 std::cerr << NF_ERROR_MESSAGE(message); \
129#define NF_THROW(message) \
130 throw NeoN::NeoNException((std::stringstream() << NF_ERROR_MESSAGE(std::string(message))).str())
144#define NF_ASSERT(condition, message) \
147 if (!(condition)) [[unlikely]] \
149 NF_ERROR_EXIT("Assertion `" #condition "` failed.\n " << message); \
167#define NF_ASSERT_THROW(condition, message) \
170 if (!(condition)) [[unlikely]] \
172 NF_THROW("Assertion `" #condition "` failed.\n " << message); \
188#define NF_DEBUG_ASSERT(condition, message) NF_ASSERT(condition, message)
201#define NF_DEBUG_ASSERT_THROW(condition, message) NF_ASSERT_THROW(condition, message)
213#define NF_DEBUG_ASSERT(condition, message) ((void)0)
226#define NF_DEBUG_ASSERT_THROW(condition, message) ((void)0)
241#define NF_ASSERT_EQUAL(a, b) NF_ASSERT(a == b, "Expected " << b << ", got " << a)
253#define NF_DEBUG_ASSERT_EQUAL(a, b) NF_DEBUG_ASSERT(a == b, "Expected " << b << ", got " << a)
268#define NF_ASSERT_EQUAL_THROW(a, b) NF_ASSERT_THROW(a == b, "Expected " << b << ", got " << a)
280#define NF_DEBUG_ASSERT_EQUAL_THROW(a, b) \
281 NF_DEBUG_ASSERT_THROW(a == b, "Expected " << b << ", got " << a)
Custom exception class for NeoN.
const char * what() const noexcept override
Returns the error message associated with the exception.
NeoNException(const std::string &message)
Constructs a NeoNException object with the given error message.