This is the class used to handle errors in the model, by displaying error messages to the user and logging information to a log file. More...
#include <errorhandler.h>
Public Member Functions | |
ErrorHandler () | |
This is the ErrorHandler constructor. More... | |
~ErrorHandler () | |
This is the default ErrorHandler destructor. More... | |
void | Open (const char *filename) |
This function will open a file for reading data from, and store the name of the file. More... | |
void | Close () |
This function will close the last file opened for reading data from. More... | |
void | checkIfFailure (ios &infile, const char *text) |
This function will check to see if an iostream can be opened, and exit Gadget with exit(EXIT_FAILURE) if this check fails. More... | |
void | setLogFile (const char *filename) |
This function will open the file that the logging information will be written to. More... | |
int | checkLogFile () |
This function will return the flag used to determine whether ta logfile exists. More... | |
void | logFinish () |
This function will log information about the finish of the current model run to std::cout and a log file if one exists. More... | |
void | logMessage (LogLevel mlevel, const char *msg) |
This function will log a warning message. More... | |
void | logMessage (LogLevel mlevel, const char *msg1, const char *msg2) |
This function will log 2 warning messages. More... | |
void | logMessage (LogLevel mlevel, const char *msg, int number) |
This function will log a warning message and a number. More... | |
void | logMessage (LogLevel mlevel, const char *msg, double number) |
This function will log a warning message and a number. More... | |
void | logMessage (LogLevel mlevel, const char *msg1, int number, const char *msg2) |
This function will log a warning message, a number and a second message. More... | |
void | logMessage (LogLevel mlevel, const char *msg1, double number, const char *msg2) |
This function will log a warning message, a number and a second message. More... | |
void | logMessage (LogLevel mlevel, DoubleVector vec) |
This function will log a vector of values. More... | |
void | logMessageNaN (LogLevel mlevel, const char *msg) |
This function will log a warning message about a NaN found in the model. More... | |
void | logFileMessage (LogLevel mlevel, const char *msg) |
This function will log a warning message generated when reading information from file. More... | |
void | logFileMessage (LogLevel mlevel, const char *msg, int number) |
This function will log a warning message and a number, generated when reading information from file. More... | |
void | logFileMessage (LogLevel mlevel, const char *msg, double number) |
This function will log a warning message and a number, generated when reading information from file. More... | |
void | logFileMessage (LogLevel mlevel, const char *msg1, const char *msg2) |
This function will log 2 warning messages generated when reading information from file. More... | |
void | logFileEOFMessage (LogLevel mlevel) |
This function will log an EOF warning message generated when reading information from file. More... | |
void | logFileUnexpected (LogLevel mlevel, const char *msg1, const char *msg2) |
This function will log an 'unexpected' warning message generated when reading information from file. More... | |
void | setRunOptimise (int opt) |
This function will set the optimise flag for the current model run. More... | |
int | getRunOptimise () const |
This function will return the optimise flag for the current model run. More... | |
void | setLogLevel (int level) |
This function will set the level of logging information used for the current model run. More... | |
LogLevel | getLogLevel () const |
This function will return the level of logging information used for the current model run. More... | |
int | getNaNFlag () const |
This function will return the flag denoting whether a NaN error has been rasied or not. More... | |
void | setNaNFlag (int flag) |
This function will return the flag denoting whether a NaN error has been rasied or not. More... | |
Protected Attributes | |
ofstream | logfile |
This ofstream is the file that all the logging information will get sent to. More... | |
StrStack * | files |
This is the StrStack of the names of files that are currently open to read from. More... | |
This is the class used to handle errors in the model, by displaying error messages to the user and logging information to a log file.
ErrorHandler::ErrorHandler | ( | ) |
This is the ErrorHandler constructor.
ErrorHandler::~ErrorHandler | ( | ) |
This is the default ErrorHandler destructor.
void ErrorHandler::checkIfFailure | ( | ios & | infile, |
const char * | text | ||
) |
This function will check to see if an iostream can be opened, and exit Gadget with exit(EXIT_FAILURE) if this check fails.
infile | is the iostream to be checked |
text | is the name of the iostream to be checked |
|
inline |
This function will return the flag used to determine whether ta logfile exists.
void ErrorHandler::Close | ( | ) |
This function will close the last file opened for reading data from.
|
inline |
This function will return the level of logging information used for the current model run.
|
inline |
This function will return the flag denoting whether a NaN error has been rasied or not.
|
inline |
This function will return the optimise flag for the current model run.
void ErrorHandler::logFileEOFMessage | ( | LogLevel | mlevel | ) |
This function will log an EOF warning message generated when reading information from file.
mlevel | is the logging level of the message to be logged |
void ErrorHandler::logFileMessage | ( | LogLevel | mlevel, |
const char * | msg | ||
) |
This function will log a warning message generated when reading information from file.
mlevel | is the logging level of the message to be logged |
msg | is the message to be logged |
void ErrorHandler::logFileMessage | ( | LogLevel | mlevel, |
const char * | msg, | ||
double | number | ||
) |
This function will log a warning message and a number, generated when reading information from file.
mlevel | is the logging level of the message to be logged |
msg | is the message to be logged |
number | is the number to be logged |
void ErrorHandler::logFileMessage | ( | LogLevel | mlevel, |
const char * | msg, | ||
int | number | ||
) |
This function will log a warning message and a number, generated when reading information from file.
mlevel | is the logging level of the message to be logged |
msg | is the message to be logged |
number | is the number to be logged |
void ErrorHandler::logFileMessage | ( | LogLevel | mlevel, |
const char * | msg1, | ||
const char * | msg2 | ||
) |
This function will log 2 warning messages generated when reading information from file.
mlevel | is the logging level of the message to be logged |
msg1 | is the first message to be logged |
msg2 | is the second message to be logged |
void ErrorHandler::logFileUnexpected | ( | LogLevel | mlevel, |
const char * | msg1, | ||
const char * | msg2 | ||
) |
This function will log an 'unexpected' warning message generated when reading information from file.
mlevel | is the logging level of the message to be logged |
msg1 | is the first (expected) message to be logged |
msg2 | is the second (unexpected) message to be logged |
void ErrorHandler::logFinish | ( | ) |
This function will log information about the finish of the current model run to std::cout and a log file if one exists.
void ErrorHandler::logMessage | ( | LogLevel | mlevel, |
const char * | msg | ||
) |
This function will log a warning message.
mlevel | is the logging level of the message to be logged |
msg | is the message to be logged |
void ErrorHandler::logMessage | ( | LogLevel | mlevel, |
const char * | msg, | ||
double | number | ||
) |
This function will log a warning message and a number.
mlevel | is the logging level of the message to be logged |
msg | is the message to be logged |
number | is the number to be logged |
void ErrorHandler::logMessage | ( | LogLevel | mlevel, |
const char * | msg, | ||
int | number | ||
) |
This function will log a warning message and a number.
mlevel | is the logging level of the message to be logged |
msg | is the message to be logged |
number | is the number to be logged |
void ErrorHandler::logMessage | ( | LogLevel | mlevel, |
const char * | msg1, | ||
const char * | msg2 | ||
) |
This function will log 2 warning messages.
mlevel | is the logging level of the message to be logged |
msg1 | is the first message to be logged |
msg2 | is the second message to be logged |
void ErrorHandler::logMessage | ( | LogLevel | mlevel, |
const char * | msg1, | ||
double | number, | ||
const char * | msg2 | ||
) |
This function will log a warning message, a number and a second message.
mlevel | is the logging level of the message to be logged |
msg1 | is the first message to be logged |
number | is the number to be logged |
msg2 | is the second message to be logged |
void ErrorHandler::logMessage | ( | LogLevel | mlevel, |
const char * | msg1, | ||
int | number, | ||
const char * | msg2 | ||
) |
This function will log a warning message, a number and a second message.
mlevel | is the logging level of the message to be logged |
msg1 | is the first message to be logged |
number | is the number to be logged |
msg2 | is the second message to be logged |
void ErrorHandler::logMessage | ( | LogLevel | mlevel, |
DoubleVector | vec | ||
) |
This function will log a vector of values.
mlevel | is the logging level of the values to be logged |
vec | is the DoubleVector of values to be logged |
void ErrorHandler::logMessageNaN | ( | LogLevel | mlevel, |
const char * | msg | ||
) |
This function will log a warning message about a NaN found in the model.
mlevel | is the logging level of the message to be logged |
msg | is the message to be logged |
void ErrorHandler::Open | ( | const char * | filename | ) |
This function will open a file for reading data from, and store the name of the file.
filename | is the name of the file |
void ErrorHandler::setLogFile | ( | const char * | filename | ) |
This function will open the file that the logging information will be written to.
filename | is the name of the file |
void ErrorHandler::setLogLevel | ( | int | level | ) |
This function will set the level of logging information used for the current model run.
level | is the logging level to be set |
|
inline |
This function will return the flag denoting whether a NaN error has been rasied or not.
|
inline |
This function will set the optimise flag for the current model run.
opt | is the optimise flag to be set |
|
protected |
This is the StrStack of the names of files that are currently open to read from.
|
protected |
This ofstream is the file that all the logging information will get sent to.