Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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.

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, ewarning, and outStream.

Referenced by Error().

{
// The user of outStream is primarily for the unit tests.
// The unit tests often generate errors on purpose to make sure
// invalid usage is flagged appropriately. Printing the error
// messages to cerr made the unit test output hard to parse.
std::string baseMsg = std::string("Level ") +
boost::lexical_cast<std::string>(level) +
std::string(" assertion violation\n") +
#if defined(NEKTAR_DEBUG) || defined(NEKTAR_FULLDEBUG)
std::string("Where : ") + boost::lexical_cast<std::string>(routine) + std::string("[") + boost::lexical_cast<std::string>(lineNumber) + std::string("]\n") + std::string("Message : ") +
#endif
msg;
switch(type)
{
case efatal:
if( outStream )
{
(*outStream) << "Fatal : " << baseMsg << std::endl;
}
else
{
std::cerr << std::endl << "Fatal : " << baseMsg << std::endl;
}
throw NekError(baseMsg);
break;
case ewarning:
if( outStream )
{
(*outStream) << "Warning: " << baseMsg << std::endl;
}
else
{
std::cerr << "Warning: " << baseMsg << std::endl;
}
break;
default:
std::cerr << "Unknown warning type: " << baseMsg << std::endl;
}
}
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().

{
Error(type, routine, lineNumber, msg.c_str(), level);
}
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().

{
Error(type, routine, lineNumber, msg, 0);
}
static bool ErrorUtil::HasCustomErrorStream ( )
inlinestatic

Definition at line 53 of file ErrorUtil.hpp.

References outStream.

{
return outStream;
}
static void ErrorUtil::SetErrorStream ( std::ostream &  o)
inlinestatic

Definition at line 48 of file ErrorUtil.hpp.

References outStream.

{
outStream = o;
}

Variable Documentation

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

Definition at line 46 of file ErrorUtil.hpp.

Referenced by Error(), HasCustomErrorStream(), and SetErrorStream().