40 #include <boost/lexical_cast.hpp> 
   41 #include <boost/optional.hpp> 
   44 #if defined(NEKTAR_USE_MPI) 
   63         return outStream ? 
true : 
false;
 
   75         NekError(
const std::string& message) : 
std::runtime_error(message) {}
 
   78     inline static void Error(
ErrType type, 
const char *routine, 
int lineNumber, 
const char *msg, 
unsigned int level)
 
   85         std::string baseMsg = std::string(
"Level ") +
 
   86             boost::lexical_cast<std::string>(level) +
 
   87             std::string(
" assertion violation\n") +
 
   88 #if defined(NEKTAR_DEBUG) || defined(NEKTAR_FULLDEBUG) 
   89             std::string(
"Where   : ") + boost::lexical_cast<std::string>(routine) +  std::string(
"[") +  boost::lexical_cast<std::string>(lineNumber) +  std::string(
"]\n") + std::string(
"Message : ") +
 
   96 #if defined(NEKTAR_USE_MPI) 
   98         MPI_Initialized(&flag);
 
  101             MPI_Comm_rank(MPI_COMM_WORLD,&rank);
 
  105         std::string btMessage(
"");
 
  106 #if defined(NEKTAR_FULLDEBUG) 
  112         btSize = backtrace(btArray, 40);
 
  113         btStrings = backtrace_symbols(btArray, btSize);
 
  115         for (
int i = 0 ; i < btSize ; ++i)
 
  117             btMessage +=  std::string(btStrings[i]) + 
"\n";
 
  130                     (*outStream) << btMessage;
 
  131                     (*outStream) << 
"Fatal   : " << baseMsg << std::endl;
 
  135                     std::cerr << btMessage;
 
  136                     std::cerr << std::endl << 
"Fatal   : " << baseMsg
 
  140 #if defined(NEKTAR_USE_MPI) 
  143                 MPI_Barrier(MPI_COMM_WORLD);
 
  153                     (*outStream) << btMessage;
 
  154                     (*outStream) << 
"Warning: " << baseMsg << std::endl;
 
  158                     std::cerr << btMessage;
 
  159                     std::cerr << 
"Warning: " << baseMsg << std::endl;
 
  164             std::cerr << 
"Unknown warning type: " << baseMsg << std::endl;
 
  168     inline static void Error(
ErrType type, 
const char *routine, 
int lineNumber, 
const std::string& msg, 
unsigned int level)
 
  170         Error(type, routine, lineNumber, msg.c_str(), level);
 
  173     inline static void Error(
ErrType type, 
const char *routine, 
int lineNumber, 
const char *msg)
 
  175         Error(type, routine, lineNumber, msg, 0);
 
  185 #define NEKERROR(type, msg) \ 
  186     ErrorUtil::Error(type, __FILE__, __LINE__, msg, 0); 
  188 #define ASSERTL0(condition,msg) \ 
  191     ErrorUtil::Error(ErrorUtil::efatal, __FILE__, __LINE__, msg, 0); \ 
  194 #define WARNINGL0(condition,msg) \ 
  197     ErrorUtil::Error(ErrorUtil::ewarning, __FILE__, __LINE__, msg, 0); \ 
  204 #if defined(NEKTAR_DEBUG) || defined(NEKTAR_FULLDEBUG) 
  206 #define ASSERTL1(condition,msg) \ 
  209     ErrorUtil::Error(ErrorUtil::efatal, __FILE__, __LINE__, msg, 1); \ 
  211 #define WARNINGL1(condition,msg) \ 
  214     ErrorUtil::Error(ErrorUtil::ewarning, __FILE__, __LINE__, msg, 0); \ 
  217 #else //defined(NEKTAR_DEBUG) || defined(NEKTAR_FULLDEBUG) 
  218 #define ASSERTL1(condition,msg) 
  219 #define WARNINGL1(condition,msg) 
  220 #endif //defined(NEKTAR_DEBUG) || defined(NEKTAR_FULLDEBUG) 
  226 #ifdef NEKTAR_FULLDEBUG 
  228 #define ASSERTL2(condition,msg) \ 
  231     ErrorUtil::Error(ErrorUtil::efatal, __FILE__, __LINE__, msg, 2); \ 
  233 #define WARNINGL2(condition,msg) \ 
  236     ErrorUtil::Error(ErrorUtil::ewarning, __FILE__, __LINE__, msg, 0); \ 
  239 #else //NEKTAR_FULLDEBUG 
  240 #define ASSERTL2(condition,msg) 
  241 #define WARNINGL2(condition,msg) 
  242 #endif //NEKTAR_FULLDEBUG 
  244 #endif //ERRORUTIL_HPP 
NekError(const std::string &message)
 
static bool HasCustomErrorStream()
 
static void SetErrorStream(std::ostream &o)
 
static boost::optional< std::ostream & > outStream
 
static void Error(ErrType type, const char *routine, int lineNumber, const char *msg, unsigned int level)