show the unhandled exceptions in debug build instead of silently eating them

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@46490 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2007-06-16 14:20:16 +00:00
parent 724b119a15
commit 1663c65500
3 changed files with 44 additions and 13 deletions

View File

@@ -45,6 +45,11 @@
#include "wx/ptr_scpd.h"
#include "wx/tokenzr.h"
#if wxUSE_EXCEPTIONS && wxUSE_STL
#include <exception>
#include <typeinfo>
#endif
#if !defined(__WXMSW__) || defined(__WXMICROWIN__)
#include <signal.h> // for SIGTRAP used by wxTrap()
#endif //Win/Unix
@@ -414,12 +419,38 @@ wxAppConsoleBase::HandleEvent(wxEvtHandler *handler,
(handler->*func)(event);
}
void wxAppConsoleBase::OnUnhandledException()
{
#ifdef __WXDEBUG__
// we're called from an exception handler so we can re-throw the exception
// to recover its type
wxString what;
try
{
throw;
}
#if wxUSE_STL
catch ( std::exception& e )
{
what.Printf("std::exception of type \"%s\", what() = \"%s\"",
typeid(e).name(), e.what());
}
#endif // wxUSE_STL
catch ( ... )
{
what = "unknown exception";
}
wxMessageOutputBest().Printf(
"*** Caught unhandled %s; terminating\n", what
);
#endif // __WXDEBUG__
}
// ----------------------------------------------------------------------------
// exceptions support
// ----------------------------------------------------------------------------
#if wxUSE_EXCEPTIONS
bool wxAppConsoleBase::OnExceptionInMainLoop()
{
throw;
@@ -430,9 +461,6 @@ bool wxAppConsoleBase::OnExceptionInMainLoop()
#endif
}
#endif // wxUSE_EXCEPTIONS
#endif // wxUSE_EXCEPTIONS
// ----------------------------------------------------------------------------