2
* This file is part of the Code::Blocks IDE and licensed under the GNU Lesser General Public License, version 3
3
* http://www.gnu.org/licenses/lgpl-3.0.html
10
#include <wx/log.h> // for wxSafeShowMessage()
13
@brief Code::Blocks error handling unit.
15
Two macros are defined to help error handling in Code::Blocks:
16
cbThrow() and cbAssert().
17
@note cbAssert() does nothing in release mode. For debug mode, compile with -DcbDEBUG
20
/** @brief The base Code::Blocks exception object. */
24
cbException(const wxString& msg, const wxString& file, int line);
25
virtual ~cbException();
27
/** @brief Display exception error message.
28
* @param safe If true, wxSafeShowMessage will be used to display the error,
29
* else a normal message box will be used.
31
void ShowErrorMessage(bool safe = true);
34
wxString Message; ///< The exception's error message.
35
wxString File; ///< The file where the exception was raised.
36
int Line; ///< The line in the file where the exception was raised.
40
#define cbThrow(message) throw cbException(message, cbC2U(__FILE__), __LINE__)
42
#define cbThrow(message) throw cbException(message, __FILE__, __LINE__)
46
#define cbAssert(expr)
48
// In unix we use kill to terminate the application, that makes gdb
49
// keep it alive which makes debugging easier.
50
// (thanks go to an unknown author)
55
#define DIE() kill(0, SIGTERM)
59
#define cbAssertMessage(expr) \
61
err.Printf(_T("Assertion failed in %s at %s:%d.\n\n%s"), cbC2U(__PRETTY_FUNCTION__).c_str(), cbC2U(__FILE__).c_str(), __LINE__, cbC2U(#expr).c_str());
63
#define cbAssertMessage(expr) \
65
err.Printf(_T("Assertion failed in %s at %s:%d.\n\n%s"), __PRETTY_FUNCTION__, __FILE__, __LINE__, #expr);
68
// non-fatal assertion
69
#define cbAssertNonFatal(expr) \
72
cbAssertMessage(expr); \
73
wxSafeShowMessage(_T("Assertion error"), err); \
77
#define cbAssert(expr) \
80
cbAssertMessage(expr); \
81
wxSafeShowMessage(_T("Fatal assertion error"), err); \
86
#endif // CBEXCEPTION_H