Module Exception Class
This class is used to throw errors from CRHM modules. These exceptions can be thrown in module routines decl, init and run but not by finish.
enum TExcept {NONE, ERR, DECLERR, WARNING, USER, TERMINATE};
class CHMException {
public:
string Message; // error message
TExcept Kind; // type of error
CHMException() : Message(""), Kind(NONE) {}; // default constructor
CHMException(string Message, TExcept Kind) : Message(Message), Kind(Kind) {};
};
Mathematical Errors
The mathematical errors: "DOMAIN","SING","OVERFLOW","UNDERFLOW","TLOSS" are handled by the C++ Exception class using
throw Exception(String("error
description"))
or throw Exception("error description")
Logging error messages.
The following two routines use Window messaging to transmit text to the CRHM log window. The routine logging the error message has to throw an exception to change program flow.
void __fastcall LogError(CHMException Except){
SendMessage(Global::crhmLog, WM_CRHM_LOG_EXCEPTION, (unsigned int) &Except, 0);
}
void __fastcall LogError(String S, TExcept Kind){
SendMessage(Global::crhmLog, WM_CRHM_LOG_EXCEPTION1, (unsigned int) &S, (unsigned int) &Kind);
}