TurtleBrains  0.3.5
High quality, portable, C++ framework for rapid 2D game development.
tb_error.hpp
1 
8 #ifndef TurtleBrains_Error_hpp
9 #define TurtleBrains_Error_hpp
10 
11 #include <string>
12 
17 
23 #define tb_error(message, ...) { tbCore::Error::TriggerError(__FILE__, __LINE__, message, ##__VA_ARGS__); }
24 
41 //#define tb_error_if(errorTest, message, ...) { tbCore::Error::TriggerErrorIf((errorTest), __FILE__, __LINE__, message, ##__VA_ARGS__); }
42 #define tb_error_if(errorTest, message, ...) { if (errorTest) { tbCore::Error::TriggerError(__FILE__, __LINE__, message, ##__VA_ARGS__); } }
43 
47 
48 namespace TurtleBrains
49 {
50  namespace Core
51  {
52  namespace Error
53  {
64  {
65  public:
70 
74  virtual ~ErrorHandlerInterface(void);
75 
83  virtual void OnErrorFired(const std::string& errorMessage) = 0;
84 
85  protected:
91  int GetLineNumber(void) const;
92 
98  const std::string& GetFileName(void) const;
99  };
100 
104  void TriggerError(const char* const message, ...);
105 
109  void TriggerError(const char* const fromFile, int onLineNumber, const char* const message, ...);
110 
117  void TriggerErrorIf(bool testResult, const char* const message, ...);
118 
125  void TriggerErrorIf(bool testResult, const char* const fromFile, int onLineNumber, const char* const message, ...);
126 
138  void AddErrorHandler(ErrorHandlerInterface *errorHandler);
139 
148  void RemoveErrorHandler(ErrorHandlerInterface *errorHandler);
149 
156  bool IsThrowingOnError(void);
157 
166  void EnableThrowOnError(void);
167 
175  void DisableThrowOnError(void);
176 
177  }; /* namespace Error */
178  }; /* namespace Core */
179 }; /* namespace TurtleBrains */
180 
181 namespace tbCore = TurtleBrains::Core;
182 
183 #endif /* TurtleBrains_Error_hpp */
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.hpp:21
Customize what happens when an error is fired.
Definition: tb_error.hpp:63
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.hpp:88