43#if defined(NEKTAR_USE_MPI)
60 NekError(
const std::string &message) :
std::runtime_error(message)
86 inline static void Error(
ErrType type, [[maybe_unused]]
const char *routine,
87 [[maybe_unused]]
int lineNumber,
const char *
msg,
89 [[maybe_unused]]
bool DoComm =
false)
97 "Level " + std::to_string(
level) +
" assertion violation\n";
98#if defined(NEKTAR_DEBUG) || defined(NEKTAR_FULLDEBUG)
99 baseMsg +=
"Where : " + std::string(routine) +
"[" +
100 std::to_string(lineNumber) +
"]\nMessage : ";
102 baseMsg += std::string(
msg);
107#if defined(NEKTAR_USE_MPI) && !defined(NEKTAR_USE_CWIPI)
111 MPI_Initialized(&flag);
114 MPI_Comm_rank(MPI_COMM_WORLD, &rank);
119 std::string btMessage(
"");
120#if defined(NEKTAR_FULLDEBUG)
128 btSize = backtrace(btArray, 40);
129 btStrings = backtrace_symbols(btArray, btSize);
131 for (
int i = 0; i < btSize; ++i)
133 btMessage += std::string(btStrings[i]) +
"\n";
147 (*m_outStream) << btMessage;
149 (*m_outStream) <<
"Fatal : " << baseMsg << std::endl;
152#if defined(NEKTAR_USE_MPI) && !defined(NEKTAR_USE_CWIPI)
157 MPI_Barrier(MPI_COMM_WORLD);
168 (*m_outStream) << btMessage;
170 (*m_outStream) <<
"Warning : " << baseMsg << std::endl;
175 <<
"Unknown warning type: " << baseMsg << std::endl;
179 inline static void Error(
ErrType type,
const char *routine,
int lineNumber,
180 const std::string &
msg,
unsigned int level)
185 inline static void Error(
ErrType type,
const char *routine,
int lineNumber,
188 Error(type, routine, lineNumber,
msg, 0);
202#define NEKERROR(type, msg) \
203 Nektar::ErrorUtil::Error(type, __FILE__, __LINE__, msg, 0);
205#define ROOTONLY_NEKERROR(type, msg) \
206 Nektar::ErrorUtil::Error(type, __FILE__, __LINE__, msg, 0, true);
208#define ASSERTL0(condition, msg) \
211 Nektar::ErrorUtil::Error(Nektar::ErrorUtil::efatal, __FILE__, \
215#define WARNINGL0(condition, msg) \
218 Nektar::ErrorUtil::Error(Nektar::ErrorUtil::ewarning, __FILE__, \
225#if defined(NEKTAR_DEBUG) || defined(NEKTAR_FULLDEBUG)
227#define ASSERTL1(condition, msg) \
230 Nektar::ErrorUtil::Error(Nektar::ErrorUtil::efatal, __FILE__, \
234#define WARNINGL1(condition, msg) \
237 Nektar::ErrorUtil::Error(Nektar::ErrorUtil::ewarning, __FILE__, \
242#define ASSERTL1(condition, msg)
243#define WARNINGL1(condition, msg)
249#ifdef NEKTAR_FULLDEBUG
251#define ASSERTL2(condition, msg) \
254 Nektar::ErrorUtil::Error(Nektar::ErrorUtil::efatal, __FILE__, \
257#define WARNINGL2(condition, msg) \
260 Nektar::ErrorUtil::Error(Nektar::ErrorUtil::ewarning, __FILE__, \
265#define ASSERTL2(condition, msg)
266#define WARNINGL2(condition, msg)
Nektar::ErrorUtil::NekError NekError
#define LIB_UTILITIES_EXPORT
NekError(const std::string &message)
static bool m_printBacktrace
static void Error(ErrType type, const char *routine, int lineNumber, const char *msg, unsigned int level, bool DoComm=false)
static void Error(ErrType type, const char *routine, int lineNumber, const char *msg)
static std::ostream * m_outStream
static void SetPrintBacktrace(bool b)
static void Error(ErrType type, const char *routine, int lineNumber, const std::string &msg, unsigned int level)
static void SetErrorStream(std::ostream &o)
static bool HasCustomErrorStream()