forked from mia/Aegisub
Handle uncaught exceptions thrown from more places
This commit is contained in:
parent
3d6cbc8c99
commit
1601c9c68d
2 changed files with 31 additions and 2 deletions
|
@ -383,8 +383,10 @@ void AegisubApp::OnFatalException() {
|
||||||
UnhandledExeception(true, frame ? frame->context.get() : nullptr);
|
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 {
|
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 {
|
try {
|
||||||
wxApp::HandleEvent(handler, func, event);
|
wxApp::HandleEvent(handler, func, event);
|
||||||
}
|
}
|
||||||
|
@ -400,9 +402,35 @@ void AegisubApp::HandleEvent(wxEvtHandler *handler, wxEventFunction func, wxEven
|
||||||
catch (const wxString &e) {
|
catch (const wxString &e) {
|
||||||
SHOW_EXCEPTION(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() {
|
int AegisubApp::OnRun() {
|
||||||
std::string error;
|
std::string error;
|
||||||
|
|
||||||
|
|
|
@ -51,6 +51,7 @@ class AegisubApp: public wxApp {
|
||||||
|
|
||||||
void OnUnhandledException() override;
|
void OnUnhandledException() override;
|
||||||
void OnFatalException() override;
|
void OnFatalException() override;
|
||||||
|
bool OnExceptionInMainLoop() override;
|
||||||
|
|
||||||
/// @brief Handle wx assertions and redirect to the logging system.
|
/// @brief Handle wx assertions and redirect to the logging system.
|
||||||
/// @param file File name
|
/// @param file File name
|
||||||
|
|
Loading…
Reference in a new issue