- wxMessageBox(_T("Unhandled exception caught, program will terminate."),
- _T("wxExcept Sample"), wxOK | wxICON_ERROR);
+ // this shows how we may let some exception propagate uncaught
+ try
+ {
+ throw;
+ }
+ catch ( UnhandledException& )
+ {
+ throw;
+ }
+ catch ( ... )
+ {
+ wxMessageBox(wxT("Unhandled exception caught, program will terminate."),
+ wxT("wxExcept Sample"), wxOK | wxICON_ERROR);
+ }
+}
+
+void MyApp::OnFatalException()
+{
+ wxMessageBox(wxT("Program has crashed and will terminate."),
+ wxT("wxExcept Sample"), wxOK | wxICON_ERROR);
+}
+
+void MyApp::OnAssertFailure(const wxChar *file,
+ int line,
+ const wxChar *func,
+ const wxChar *cond,
+ const wxChar *msg)
+{
+ // take care to not show the message box from a worker thread, this doesn't
+ // work as it doesn't have any event loop
+ if ( !wxIsMainThread() ||
+ wxMessageBox
+ (
+ wxString::Format("An assert failed in %s().", func) +
+ "\n"
+ "Do you want to call the default assert handler?",
+ "wxExcept Sample",
+ wxYES_NO | wxICON_QUESTION
+ ) == wxYES )
+ {
+ wxApp::OnAssertFailure(file, line, func, cond, msg);
+ }