Handle uncaught exceptions thrown from more places

This commit is contained in:
Thomas Goyne 2013-12-23 09:07:20 -08:00
parent 3d6cbc8c99
commit 1601c9c68d
2 changed files with 31 additions and 2 deletions

View file

@ -383,8 +383,10 @@ void AegisubApp::OnFatalException() {
UnhandledExeception(true, frame ? frame->context.get() : nullptr);
}
#define SHOW_EXCEPTION(str) \
wxMessageBox(wxString::Format(_("An unexpected error has occurred. Please save your work and restart Aegisub.\n\nError Message: %s"), str), \
"Exception in event handler", wxOK | wxICON_ERROR | wxCENTER | wxSTAY_ON_TOP)
void AegisubApp::HandleEvent(wxEvtHandler *handler, wxEventFunction func, wxEvent& event) const {
#define SHOW_EXCEPTION(str) wxMessageBox(str, "Exception in event handler", wxOK | wxICON_ERROR | wxCENTER | wxSTAY_ON_TOP)
try {
wxApp::HandleEvent(handler, func, event);
}
@ -400,9 +402,35 @@ void AegisubApp::HandleEvent(wxEvtHandler *handler, wxEventFunction func, wxEven
catch (const wxString &e) {
SHOW_EXCEPTION(e);
}
#undef SHOW_EXCEPTION
catch (...) {
SHOW_EXCEPTION("Unknown error");
}
}
bool AegisubApp::OnExceptionInMainLoop() {
try {
throw;
}
catch (const agi::Exception &e) {
SHOW_EXCEPTION(to_wx(e.GetChainedMessage()));
}
catch (const std::exception &e) {
SHOW_EXCEPTION(to_wx(e.what()));
}
catch (const char *e) {
SHOW_EXCEPTION(to_wx(e));
}
catch (const wxString &e) {
SHOW_EXCEPTION(e);
}
catch (...) {
SHOW_EXCEPTION("Unknown error");
}
return true;
}
#undef SHOW_EXCEPTION
int AegisubApp::OnRun() {
std::string error;

View file

@ -51,6 +51,7 @@ class AegisubApp: public wxApp {
void OnUnhandledException() override;
void OnFatalException() override;
bool OnExceptionInMainLoop() override;
/// @brief Handle wx assertions and redirect to the logging system.
/// @param file File name