Nektar++
Classes | Enumerations | Functions | Variables
ErrorUtil Namespace Reference

Classes

class  NekError
 

Enumerations

enum  ErrType { efatal, ewarning }
 

Functions

static void SetErrorStream (std::ostream &o)
 
static bool HasCustomErrorStream ()
 
static void Error (ErrType type, const char *routine, int lineNumber, const char *msg, unsigned int level)
 
static void Error (ErrType type, const char *routine, int lineNumber, const std::string &msg, unsigned int level)
 
static void Error (ErrType type, const char *routine, int lineNumber, const char *msg)
 

Variables

static boost::optional< std::ostream & > outStream
 

Enumeration Type Documentation

Enumerator
efatal 
ewarning 

Definition at line 58 of file ErrorUtil.hpp.

59  {
60  efatal,
61  ewarning
62  };

Function Documentation

static void ErrorUtil::Error ( ErrType  type,
const char *  routine,
int  lineNumber,
const char *  msg,
unsigned int  level 
)
inlinestatic

Definition at line 70 of file ErrorUtil.hpp.

References efatal, and ewarning.

Referenced by Error().

71  {
72  // The user of outStream is primarily for the unit tests.
73  // The unit tests often generate errors on purpose to make sure
74  // invalid usage is flagged appropriately. Printing the error
75  // messages to cerr made the unit test output hard to parse.
76 
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 : ") +
82 #endif
83  msg;
84 
85  switch(type)
86  {
87  case efatal:
88  if( outStream )
89  {
90  (*outStream) << "Fatal : " << baseMsg << std::endl;
91  }
92  else
93  {
94  std::cerr << std::endl << "Fatal : " << baseMsg << std::endl;
95  }
96  throw NekError(baseMsg);
97  break;
98 
99  case ewarning:
100  if( outStream )
101  {
102  (*outStream) << "Warning: " << baseMsg << std::endl;
103  }
104  else
105  {
106  std::cerr << "Warning: " << baseMsg << std::endl;
107  }
108  break;
109 
110  default:
111  std::cerr << "Unknown warning type: " << baseMsg << std::endl;
112  }
113  }
static boost::optional< std::ostream & > outStream
Definition: ErrorUtil.hpp:46
static void ErrorUtil::Error ( ErrType  type,
const char *  routine,
int  lineNumber,
const std::string &  msg,
unsigned int  level 
)
inlinestatic

Definition at line 115 of file ErrorUtil.hpp.

References Error().

116  {
117  Error(type, routine, lineNumber, msg.c_str(), level);
118  }
static void Error(ErrType type, const char *routine, int lineNumber, const char *msg)
Definition: ErrorUtil.hpp:120
static void ErrorUtil::Error ( ErrType  type,
const char *  routine,
int  lineNumber,
const char *  msg 
)
inlinestatic

Definition at line 120 of file ErrorUtil.hpp.

References Error().

121  {
122  Error(type, routine, lineNumber, msg, 0);
123  }
static void Error(ErrType type, const char *routine, int lineNumber, const char *msg)
Definition: ErrorUtil.hpp:120
static bool ErrorUtil::HasCustomErrorStream ( )
inlinestatic

Definition at line 53 of file ErrorUtil.hpp.

54  {
55  return outStream ? true : false;
56  }
static boost::optional< std::ostream & > outStream
Definition: ErrorUtil.hpp:46
static void ErrorUtil::SetErrorStream ( std::ostream &  o)
inlinestatic

Definition at line 48 of file ErrorUtil.hpp.

49  {
50  outStream = o;
51  }
static boost::optional< std::ostream & > outStream
Definition: ErrorUtil.hpp:46

Variable Documentation

boost::optional<std::ostream&> ErrorUtil::outStream
static

Definition at line 46 of file ErrorUtil.hpp.