40 #include <boost/lexical_cast.hpp>
41 #include <boost/optional.hpp>
67 NekError(
const std::string& message) : std::runtime_error(message) {}
70 inline static void Error(
ErrType type,
const char *routine,
int lineNumber,
const char *msg,
unsigned int level)
77 std::string baseMsg = std::string(
"Level ") +
78 boost::lexical_cast<std::string>(level) +
79 std::string(
" assertion violation\n") +
80 #if defined(NEKTAR_DEBUG) || defined(NEKTAR_FULLDEBUG)
81 std::string(
"Where : ") + boost::lexical_cast<std::string>(routine) + std::string(
"[") + boost::lexical_cast<std::string>(lineNumber) + std::string(
"]\n") + std::string(
"Message : ") +
90 (*outStream) <<
"Fatal : " << baseMsg << std::endl;
94 std::cerr << std::endl <<
"Fatal : " << baseMsg << std::endl;
102 (*outStream) <<
"Warning: " << baseMsg << std::endl;
106 std::cerr <<
"Warning: " << baseMsg << std::endl;
111 std::cerr <<
"Unknown warning type: " << baseMsg << std::endl;
115 inline static void Error(
ErrType type,
const char *routine,
int lineNumber,
const std::string& msg,
unsigned int level)
117 Error(type, routine, lineNumber, msg.c_str(), level);
120 inline static void Error(
ErrType type,
const char *routine,
int lineNumber,
const char *msg)
122 Error(type, routine, lineNumber, msg, 0);
132 #define NEKERROR(type, msg) \
133 ErrorUtil::Error(type, __FILE__, __LINE__, msg, 0);
135 #define ASSERTL0(condition,msg) \
138 ErrorUtil::Error(ErrorUtil::efatal, __FILE__, __LINE__, msg, 0); \
141 #define WARNINGL0(condition,msg) \
144 ErrorUtil::Error(ErrorUtil::ewarning, __FILE__, __LINE__, msg, 0); \
151 #if defined(NEKTAR_DEBUG) || defined(NEKTAR_FULLDEBUG)
153 #define ASSERTL1(condition,msg) \
156 ErrorUtil::Error(ErrorUtil::efatal, __FILE__, __LINE__, msg, 1); \
158 #define WARNINGL1(condition,msg) \
161 ErrorUtil::Error(ErrorUtil::ewarning, __FILE__, __LINE__, msg, 0); \
164 #else //defined(NEKTAR_DEBUG) || defined(NEKTAR_FULLDEBUG)
165 #define ASSERTL1(condition,msg)
166 #define WARNINGL1(condition,msg)
167 #endif //defined(NEKTAR_DEBUG) || defined(NEKTAR_FULLDEBUG)
173 #ifdef NEKTAR_FULLDEBUG
175 #define ASSERTL2(condition,msg) \
178 ErrorUtil::Error(ErrorUtil::efatal, __FILE__, __LINE__, msg, 2); \
180 #define WARNINGL2(condition,msg) \
183 ErrorUtil::Error(ErrorUtil::ewarning, __FILE__, __LINE__, msg, 0); \
186 #else //NEKTAR_FULLDEBUG
187 #define ASSERTL2(condition,msg)
188 #define WARNINGL2(condition,msg)
189 #endif //NEKTAR_FULLDEBUG
191 #endif //ERRORUTIL_HPP