41 #include <boost/core/ignore_unused.hpp>
45 #if defined(NEKTAR_USE_MPI)
62 NekError(
const std::string &message) : std::runtime_error(message)
88 inline static void Error(
ErrType type,
const char *routine,
int lineNumber,
92 boost::ignore_unused(DoComm);
100 "Level " + std::to_string(
level) +
" assertion violation\n";
101 #if defined(NEKTAR_DEBUG) || defined(NEKTAR_FULLDEBUG)
102 baseMsg +=
"Where : " + std::string(routine) +
"[" +
103 std::to_string(lineNumber) +
"]\nMessage : ";
105 boost::ignore_unused(routine, lineNumber);
107 baseMsg += std::string(
msg);
112 #if defined(NEKTAR_USE_MPI) && !defined(NEKTAR_USE_CWIPI)
116 MPI_Initialized(&flag);
119 MPI_Comm_rank(MPI_COMM_WORLD, &rank);
123 boost::ignore_unused(DoComm);
126 std::string btMessage(
"");
127 #if defined(NEKTAR_FULLDEBUG)
135 btSize = backtrace(btArray, 40);
136 btStrings = backtrace_symbols(btArray, btSize);
138 for (
int i = 0; i < btSize; ++i)
140 btMessage += std::string(btStrings[i]) +
"\n";
154 (*m_outStream) << btMessage;
156 (*m_outStream) <<
"Fatal : " << baseMsg << std::endl;
159 #if defined(NEKTAR_USE_MPI) && !defined(NEKTAR_USE_CWIPI)
164 MPI_Barrier(MPI_COMM_WORLD);
175 (*m_outStream) << btMessage;
177 (*m_outStream) <<
"Warning : " << baseMsg << std::endl;
182 <<
"Unknown warning type: " << baseMsg << std::endl;
186 inline static void Error(
ErrType type,
const char *routine,
int lineNumber,
187 const std::string &
msg,
unsigned int level)
192 inline static void Error(
ErrType type,
const char *routine,
int lineNumber,
195 Error(type, routine, lineNumber,
msg, 0);
209 #define NEKERROR(type, msg) \
210 Nektar::ErrorUtil::Error(type, __FILE__, __LINE__, msg, 0);
212 #define ROOTONLY_NEKERROR(type, msg) \
213 Nektar::ErrorUtil::Error(type, __FILE__, __LINE__, msg, 0, true);
215 #define ASSERTL0(condition, msg) \
218 Nektar::ErrorUtil::Error(Nektar::ErrorUtil::efatal, __FILE__, \
222 #define WARNINGL0(condition, msg) \
225 Nektar::ErrorUtil::Error(Nektar::ErrorUtil::ewarning, __FILE__, \
232 #if defined(NEKTAR_DEBUG) || defined(NEKTAR_FULLDEBUG)
234 #define ASSERTL1(condition, msg) \
237 Nektar::ErrorUtil::Error(Nektar::ErrorUtil::efatal, __FILE__, \
241 #define WARNINGL1(condition, msg) \
244 Nektar::ErrorUtil::Error(Nektar::ErrorUtil::ewarning, __FILE__, \
249 #define ASSERTL1(condition, msg)
250 #define WARNINGL1(condition, msg)
256 #ifdef NEKTAR_FULLDEBUG
258 #define ASSERTL2(condition, msg) \
261 Nektar::ErrorUtil::Error(Nektar::ErrorUtil::efatal, __FILE__, \
264 #define WARNINGL2(condition, msg) \
267 Nektar::ErrorUtil::Error(Nektar::ErrorUtil::ewarning, __FILE__, \
272 #define ASSERTL2(condition, msg)
273 #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()
The above copyright notice and this permission notice shall be included.