41 #include <boost/core/ignore_unused.hpp>
45 #if defined(NEKTAR_USE_MPI)
62 NekError(
const std::string& message) : std::runtime_error(message)
95 boost::ignore_unused(DoComm);
102 std::string baseMsg =
"Level " + std::to_string(
level) +
103 " assertion violation\n";
104 #if defined(NEKTAR_DEBUG) || defined(NEKTAR_FULLDEBUG)
105 baseMsg +=
"Where : " + std::string(routine) +
"[" +
106 std::to_string(lineNumber) +
"]\nMessage : ";
108 boost::ignore_unused(routine, lineNumber);
110 baseMsg += std::string(
msg);
115 #if defined(NEKTAR_USE_MPI) && !defined(NEKTAR_USE_CWIPI)
119 MPI_Initialized(&flag);
122 MPI_Comm_rank(MPI_COMM_WORLD,&rank);
126 boost::ignore_unused(DoComm);
129 std::string btMessage(
"");
130 #if defined(NEKTAR_FULLDEBUG)
138 btSize = backtrace(btArray, 40);
139 btStrings = backtrace_symbols(btArray, btSize);
141 for (
int i = 0 ; i < btSize ; ++i)
143 btMessage += std::string(btStrings[i]) +
"\n";
157 (*m_outStream) << btMessage;
159 (*m_outStream) <<
"Fatal : " << baseMsg << std::endl;
162 #if defined(NEKTAR_USE_MPI) && !defined(NEKTAR_USE_CWIPI)
167 MPI_Barrier(MPI_COMM_WORLD);
178 (*m_outStream) << btMessage;
180 (*m_outStream) <<
"Warning : " << baseMsg << std::endl;
184 (*m_outStream) <<
"Unknown warning type: " << baseMsg << std::endl;
188 inline static void Error(
ErrType type,
const char *routine,
int lineNumber,
const std::string&
msg,
unsigned int level)
193 inline static void Error(
ErrType type,
const char *routine,
int lineNumber,
const char *
msg)
195 Error(type, routine, lineNumber,
msg, 0);
209 #define NEKERROR(type, msg) \
210 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( \
220 Nektar::ErrorUtil::efatal, __FILE__, __LINE__, msg, 0); \
223 #define WARNINGL0(condition,msg) \
226 Nektar::ErrorUtil::Error( \
227 Nektar::ErrorUtil::ewarning, __FILE__, __LINE__, msg, 0); \
233 #if defined(NEKTAR_DEBUG) || defined(NEKTAR_FULLDEBUG)
235 #define ASSERTL1(condition,msg) \
238 Nektar::ErrorUtil::Error( \
239 Nektar::ErrorUtil::efatal, __FILE__, __LINE__, msg, 1); \
242 #define WARNINGL1(condition,msg) \
245 Nektar::ErrorUtil::Error( \
246 Nektar::ErrorUtil::ewarning, __FILE__, __LINE__, msg, 1); \
250 #define ASSERTL1(condition,msg)
251 #define WARNINGL1(condition,msg)
258 #ifdef NEKTAR_FULLDEBUG
260 #define ASSERTL2(condition,msg) \
263 Nektar::ErrorUtil::Error( \
264 Nektar::ErrorUtil::efatal, __FILE__, __LINE__, msg, 2); \
266 #define WARNINGL2(condition,msg) \
269 Nektar::ErrorUtil::Error( \
270 Nektar::ErrorUtil::ewarning, __FILE__, __LINE__, msg, 2); \
274 #define ASSERTL2(condition,msg)
275 #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.