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 
51 #define tb_static_error_if(errorTest, message) static_assert(!(errorTest), message)
52 
56 
58 {
69  {
70  public:
75 
79  virtual ~ErrorHandlerInterface(void);
80 
88  virtual void OnErrorFired(const std::string& errorMessage) = 0;
89 
90  protected:
96  int GetLineNumber(void) const;
97 
103  const std::string& GetFileName(void) const;
104  };
105 
109  void TriggerError(const char* const message, ...);
110 
114  void TriggerError(const char* const fromFile, int onLineNumber, const char* const message, ...);
115 
122  void TriggerErrorIf(bool testResult, const char* const message, ...);
123 
130  void TriggerErrorIf(bool testResult, const char* const fromFile, int onLineNumber, const char* const message, ...);
131 
144 
154 
161  bool IsThrowingOnError(void);
162 
171  void EnableThrowOnError(void);
172 
181 
185  std::string GetErrorString(int errorNumber);
186 
187 }; /* namespace TurtleBrains::Core::Error */
188 
189 namespace tbCore = TurtleBrains::Core;
190 
191 #endif /* TurtleBrains_Error_hpp */
Customize what happens when an error is fired.
Definition: tb_error.hpp:69
const std::string & GetFileName(void) const
virtual void OnErrorFired(const std::string &errorMessage)=0
Contains defines and functionality for protecting the framework and your project from disaster.
Definition: tb_error.hpp:58
void RemoveErrorHandler(ErrorHandlerInterface *errorHandler)
void TriggerErrorIf(bool testResult, const char *const message,...)
void AddErrorHandler(ErrorHandlerInterface *errorHandler)
void TriggerError(const char *const message,...)
Contains core functionality for each component of the API.
Definition: tb_debug_logger.hpp:125