PSCF v1.1
Public Member Functions | Protected Attributes | List of all members
Util::Exception Class Reference

A user-defined exception. More...

#include <Exception.h>

Inheritance diagram for Util::Exception:
Pscf::NanException

Public Member Functions

 Exception (const char *function, const char *message, const char *file, int line, int echo=1)
 Constructor. More...
 
 Exception (const char *message, const char *file, int line, int echo=1)
 Constructor without function name parameter. More...
 
virtual ~Exception ()
 Destructor. More...
 
void write (std::ostream &out)
 Write error message to output stream. More...
 
std::string & message ()
 Return the error message. More...
 

Protected Attributes

std::string message_
 Error message string. More...
 

Detailed Description

A user-defined exception.

Exceptions are usually thrown using the UTIL_THROW() macro.

Definition at line 24 of file Exception.h.

Constructor & Destructor Documentation

◆ Exception() [1/2]

Util::Exception::Exception ( const char *  function,
const char *  message,
const char *  file,
int  line,
int  echo = 1 
)

Constructor.

Constructs error message that includes file and line number. Values of the file and line parameters should be given by the built-in macros FILE and LINE, respectively, in the calling function. A typical call of the constructor is thus of the form:

throw Exception("MyClass::myFunction", "A terrible thing happened!",
__FILE__, __LINE__ );
A user-defined exception.
Definition: Exception.h:25
Parameters
functionname of the function from which the Exception was thrown
messagemessage describing the nature of the error
filename of the file from which the Exception was thrown
lineline number in file
echoif echo, then echo to Log::file() when constructed.

Definition at line 22 of file Exception.cpp.

References Util::Log::file(), message(), message_, and write().

◆ Exception() [2/2]

Util::Exception::Exception ( const char *  message,
const char *  file,
int  line,
int  echo = 1 
)

Constructor without function name parameter.

Parameters
messagemessage describing the nature of the error
filename of the file from which the Exception was thrown
lineline number in file
echoif echo, then echo to std out when constructed.

Definition at line 48 of file Exception.cpp.

References Util::Log::file(), message(), message_, and write().

◆ ~Exception()

Util::Exception::~Exception ( )
virtual

Destructor.

Definition at line 71 of file Exception.cpp.

Member Function Documentation

◆ write()

void Util::Exception::write ( std::ostream &  out)

Write error message to output stream.

Parameters
outoutput stream

Definition at line 77 of file Exception.cpp.

References message_.

Referenced by Exception().

◆ message()

std::string & Util::Exception::message ( )

Return the error message.

Definition at line 83 of file Exception.cpp.

References message_.

Referenced by Exception(), and Util::MpiThrow().

Member Data Documentation

◆ message_

std::string Util::Exception::message_
protected

Error message string.

Definition at line 80 of file Exception.h.

Referenced by Exception(), message(), and write().


The documentation for this class was generated from the following files: