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;
151 <<
"\033[31mFatal : \033[0m" << baseMsg << std::endl
155#if defined(NEKTAR_USE_MPI) && !defined(NEKTAR_USE_CWIPI)
160 MPI_Barrier(MPI_COMM_WORLD);
171 (*m_outStream) << btMessage;
175 <<
"\033[36mWarning : \033[0m" << baseMsg << std::endl
180 (*m_outStream) << std::endl
181 <<
"\033[35mUnknown warning type: \033[0m"
182 << baseMsg << std::endl
187 inline static void Error(
ErrType type,
const char *routine,
int lineNumber,
188 const std::string &msg,
unsigned int level)
190 Error(type, routine, lineNumber, msg.c_str(), level);
193 inline static void Error(
ErrType type,
const char *routine,
int lineNumber,
196 Error(type, routine, lineNumber, msg, 0);
210#define NEKERROR(type, msg) \
211 Nektar::ErrorUtil::Error(type, __FILE__, __LINE__, msg, 0);
213#define ROOTONLY_NEKERROR(type, msg) \
214 Nektar::ErrorUtil::Error(type, __FILE__, __LINE__, msg, 0, true);
216#define ASSERTL0(condition, msg) \
219 Nektar::ErrorUtil::Error(Nektar::ErrorUtil::efatal, __FILE__, \
223#define WARNINGL0(condition, msg) \
226 Nektar::ErrorUtil::Error(Nektar::ErrorUtil::ewarning, __FILE__, \
233#if defined(NEKTAR_DEBUG) || defined(NEKTAR_FULLDEBUG)
235#define ASSERTL1(condition, msg) \
238 Nektar::ErrorUtil::Error(Nektar::ErrorUtil::efatal, __FILE__, \
242#define WARNINGL1(condition, msg) \
245 Nektar::ErrorUtil::Error(Nektar::ErrorUtil::ewarning, __FILE__, \
250#define ASSERTL1(condition, msg)
251#define WARNINGL1(condition, msg)
257#ifdef NEKTAR_FULLDEBUG
259#define ASSERTL2(condition, msg) \
262 Nektar::ErrorUtil::Error(Nektar::ErrorUtil::efatal, __FILE__, \
265#define WARNINGL2(condition, msg) \
268 Nektar::ErrorUtil::Error(Nektar::ErrorUtil::ewarning, __FILE__, \
273#define ASSERTL2(condition, msg)
274#define WARNINGL2(condition, msg)
#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()