Files CCore/inc/gadget/ExceptionType.h CCore/src/gadget/ExceptionType.cpp
ExceptionType is an enum with two named values. It is used to handle an exceptional situation in CCore.
enum ExceptionType { NoException, // don't throw exception, just report a error Exception // throw exception };
CatchType is an empty base class for exception classes.
struct CatchType
{
CatchType() {}
};
CCore uses the following pattern to handle exceptional situations. To throw an exception:
Printf(Exception,"message text",....);
This statement picks up an installed error report handler, prints the specified error message and then throws an exception of type CatchType.
To report a error without throwing an exception (i.e. inside a destructor):
Printf(NoException,"message text",....);
To catch exceptions use the following pattern:
try { ReportException report; // or some derived from the ReportException class { // do some job here } report.guard(); // throw an exception if there was Printf(NoException,....); above } catch(CatchType) { // handle exception }
See Exceptions for more details.