Contains defines and functionality for protecting the framework and your project from disaster. More...
Classes | |
| class | ErrorHandlerInterface |
| Customize what happens when an error is fired. More... | |
Functions | |
| void | TriggerError (const char *const message,...) |
| void | TriggerError (const char *const fromFile, int onLineNumber, const char *const message,...) |
| void | TriggerErrorIf (bool testResult, const char *const message,...) |
| void | TriggerErrorIf (bool testResult, const char *const fromFile, int onLineNumber, const char *const message,...) |
| void | AddErrorHandler (ErrorHandlerInterface *errorHandler) |
| void | RemoveErrorHandler (ErrorHandlerInterface *errorHandler) |
| bool | IsThrowingOnError (void) |
| void | EnableThrowOnError (void) |
| void | DisableThrowOnError (void) |
| std::string | GetErrorString (int errorNumber) |
Disasters will happen, they are natural after all. Mistakes will happen and to minimize the mistakes made from misusing a function or object can be protected by defensive programming. As much as possible, the functions and objects in TurtleBrains will trigger an error when misused. Several options exist for how a triggered error can be handled. Exceptions can be thrown, assertions fired, or a custom handler can be created using the ErrorHandlerInterface.
| void TurtleBrains::Core::Error::AddErrorHandler | ( | ErrorHandlerInterface * | errorHandler | ) |
Each ErrorHandlerInterface will have a chance to handle a fired error, in the order they were added unless the path of the code is modified by termination, exceptions or other means within a handler.
| errorHandler | The errorHandler to be added, must be non-null. |
| void TurtleBrains::Core::Error::DisableThrowOnError | ( | void | ) |
Disables the exception throwing upon a triggered error condition, which can be enabled or disabled at runtime by calling this or EnableThrowOnError(). When disabled, the triggered error condition will be handled through the stack of errorHandlers added via AddErrorHandler().
| void TurtleBrains::Core::Error::EnableThrowOnError | ( | void | ) |
Instead of firing each ErrorHandlerInterface when an error is fired, this will throw an exception which can be caught and handled by the application developer. By default, exception throwing is disabled.
| bool TurtleBrains::Core::Error::IsThrowingOnError | ( | void | ) |
Check to see if the error handler is to throw an exception instead of firing each ErrorHandler when an error condition is triggered.
| void TurtleBrains::Core::Error::RemoveErrorHandler | ( | ErrorHandlerInterface * | errorHandler | ) |
Removes a handler from the list of handlers.
| errorHandler | The errorHandler to be added, must be non-null. |
| void TurtleBrains::Core::Error::TriggerError | ( | const char *const | fromFile, |
| int | onLineNumber, | ||
| const char *const | message, | ||
| ... | |||
| ) |
Triggers an error condition so OnErrorFired() will be called and all error handlers will be notified.
| void TurtleBrains::Core::Error::TriggerError | ( | const char *const | message, |
| ... | |||
| ) |
Triggers an error condition so OnErrorFired() will be called and all error handlers will be notified.
| void TurtleBrains::Core::Error::TriggerErrorIf | ( | bool | testResult, |
| const char *const | fromFile, | ||
| int | onLineNumber, | ||
| const char *const | message, | ||
| ... | |||
| ) |
If testResult is true, OnErrorFired() will be called and all error handlers will be notified.
| void TurtleBrains::Core::Error::TriggerErrorIf | ( | bool | testResult, |
| const char *const | message, | ||
| ... | |||
| ) |
If testResult is true, OnErrorFired() will be called and all error handlers will be notified.