PSCF v1.1
Public Member Functions | List of all members
Pscf::NanException Class Reference

Exception thrown when not-a-number (NaN) is encountered. More...

#include <NanException.h>

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

Public Member Functions

 NanException (const char *function, const char *file, int line, int echo=1)
 Constructor. More...
 
 NanException (const char *file, int line, int echo=1)
 Constructor without function name parameter. More...
 
 ~NanException ()
 Destructor. More...
 
- Public Member Functions inherited from Util::Exception
 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...
 

Additional Inherited Members

- Protected Attributes inherited from Util::Exception
std::string message_
 Error message string. More...
 

Detailed Description

Exception thrown when not-a-number (NaN) is encountered.

An exception to be thrown when a required numerical parameter has a value of NaN. This may happen, for instance, as a result of dividing by zero. A NanException is used rather than a generic Exception in these instances so that the NanException can be caught by a try-catch block.

A NanException behaves identically to a generic Exception, but with a pre-defined error message rather than a user-specified message. There is no preprocessor macro to throw a NanException, so they must be thrown using the constructor. This will typically assume the following syntax, where values of the file and line parameters are given by the built-in macros FILE and LINE, respectively:

throw Exception("MyClass::myFunction", __FILE__, __LINE__ );
A user-defined exception.
Definition: Exception.h:25

Definition at line 39 of file NanException.h.

Constructor & Destructor Documentation

◆ NanException() [1/2]

Pscf::NanException::NanException ( const char *  function,
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.

Parameters
functionname of the function from which the Exception was thrown
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 19 of file NanException.cpp.

◆ NanException() [2/2]

Pscf::NanException::NanException ( const char *  file,
int  line,
int  echo = 1 
)

Constructor without function name parameter.

Parameters
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 28 of file NanException.cpp.

◆ ~NanException()

Pscf::NanException::~NanException ( )

Destructor.

Definition at line 36 of file NanException.cpp.


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