|
SCATMECH > Classes and Functions >
Utility >
SCATMECH_exception
class SCATMECH_exception
The class SCATMECH_exception is provided to enable
exception handling. Any fatal error by any SCATMECH
function will throw an exception of type
SCATMECH_exception. Since it inherits the class
std::exception, any program which catches exceptions
of type std::exception will catch exceptions of type
SCATMECH_exception.
Include file:
#include "scatmech.h"
Source code:
askuser.cpp
See also:
SCATMECH
Home
Definition of public elements:
class SCATMECH_exception : public std::exception
{
enum { Warning = 1, Fatal = 2 };
enum { Handler_Exists = 0, No_Handler_Exists = 1 };
SCATMECH_exception(const std::string& m,int l=SCATMECH_exception::Fatal);
~SCATMECH_exception() throw() {};
virtual const char *what() const throw();
static void set_mode(int m=SCATMECH_exception::No_Handler_Exists);
};
This function returns a pointer to a string
containing the error message.
Example:
try {
// ... set of code containing SCATMECH routines
}
catch(SCATMECH_exception& e)
{
cerr << e.what() << endl;
exit(0);
}
Top of Page
The function set_mode allows the programmer to
set a state indicating whether or not an error handler
(try/catch statements) exists. Setting this mode to
SCATMECH_exception::No_Handler_Exists indicates
that an error message should be written to cerr
and the program exited if an exception is thrown. If the
mode is set to SCATMECH_exception::Handler_Exists,
then the error handler is assumed to exist and to
appropriately notify the user of the error (using
what()). By default, the mode is set
to SCATMECH_exception::No_Handler_Exists.
Example:
SCATMECH_exception::set_mode(SCATMECH_exception::Handler_Exists);
try {
// ... set of code containing SCATMECH routines
}
catch(SCATMECH_exception& e)
{
cerr << e.what() << endl;
exit(0);
}
Top of Page
For More Information
SCATMECH Technical Information and Questions
Optical Technology Division (OTD) Home Page
OTD Technical Inquiries
OTD Website Comments
Current SCATMECH version: 6.00 (February 2008)
This page first online: Version 3.00 (December 2001)
This page last modified: Version 6.00 (February 2008)
|