TurtleBrains  0.3.1
High quality, portable, C++ framework for rapid 2D game development.
tb_error.h
1 
8 #ifndef _TurtleBrains_Error_h_
9 #define _TurtleBrains_Error_h_
10 
11 #include <string>
12 
17 
23 #define tb_error(message, ...) { tbCore::Error::TriggerError(__FILE__, __LINE__, message, ##__VA_ARGS__); }
24 
37 #define tb_error_if(errorTest, message, ...) { tbCore::Error::TriggerErrorIf((errorTest), __FILE__, __LINE__, message, ##__VA_ARGS__); }
38 
42 
43 namespace TurtleBrains
44 {
45  namespace Core
46  {
47  namespace Error
48  {
59  {
60  public:
65 
69  virtual ~ErrorHandlerInterface(void);
70 
78  virtual void OnErrorFired(const std::string& errorMessage) = 0;
79 
80  protected:
86  int GetLineNumber(void) const;
87 
93  const std::string& GetFileName(void) const;
94  };
95 
99  void TriggerError(const char* const message, ...);
100 
104  void TriggerError(const char* const fromFile, int onLineNumber, const char* const message, ...);
105 
112  void TriggerErrorIf(bool testResult, const char* const message, ...);
113 
120  void TriggerErrorIf(bool testResult, const char* const fromFile, int onLineNumber, const char* const message, ...);
121 
133  void AddErrorHandler(ErrorHandlerInterface *errorHandler);
134 
143  void RemoveErrorHandler(ErrorHandlerInterface *errorHandler);
144 
153  void EnableThrowOnError(void);
154 
162  void DisableThrowOnError(void);
163 
164  }; /* namespace Error */
165  }; /* namespace Core */
166 }; /* namespace TurtleBrains */
167 
168 namespace tbCore = TurtleBrains::Core;
169 
170 #endif /* _TurtleBrains_Error_h_ */
void RemoveErrorHandler(ErrorHandlerInterface *errorHandler)
const std::string & GetFileName(void) const
virtual void OnErrorFired(const std::string &errorMessage)=0
void TriggerError(const char *const message,...)
Here is some information about the primary namespace.
Definition: tb_application_dialog.h:21
Customize what happens when an error is fired.
Definition: tb_error.h:58
void AddErrorHandler(ErrorHandlerInterface *errorHandler)
void TriggerErrorIf(bool testResult, const char *const message,...)
Contains core functionality for each component of the API.
Definition: tb_debug_logger.h:91