From 5bd0981a7248acdd0a5bfff969b8fdfa4ae16161 Mon Sep 17 00:00:00 2001 From: Niels Martin Hansen Date: Sun, 20 Jun 2010 19:03:05 +0000 Subject: [PATCH] Make AssFile::Load catch agi::Exception and report it properly. The catching of reading/parsing errors probably doesn't really belong there, but just making things work for now. Updates #1213 in preparation for the actual patch. Originally committed to SVN as r4555. --- aegisub/src/ass_file.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/aegisub/src/ass_file.cpp b/aegisub/src/ass_file.cpp index 89d51c2d9..4b3e4bdfb 100644 --- a/aegisub/src/ass_file.cpp +++ b/aegisub/src/ass_file.cpp @@ -72,7 +72,7 @@ AssFile::~AssFile() { } void AssFile::Load (const wxString &_filename,wxString charset,bool addToRecent) { - bool ok = true; + bool ok = false; try { // Try to open file @@ -102,6 +102,7 @@ void AssFile::Load (const wxString &_filename,wxString charset,bool addToRecent) if (reader) { reader->SetTarget(this); reader->ReadFile(_filename,charset); + ok = true; } // Couldn't find a type @@ -111,18 +112,20 @@ void AssFile::Load (const wxString &_filename,wxString charset,bool addToRecent) // String error catch (const wchar_t *except) { wxMessageBox(except,_T("Error loading file"),wxICON_ERROR | wxOK); - ok = false; } catch (wxString except) { wxMessageBox(except,_T("Error loading file"),wxICON_ERROR | wxOK); - ok = false; + } + + // Real exception + catch (agi::Exception &e) { + wxMessageBox(wxString(e.GetChainedMessage().c_str(), wxConvUTF8), L"Error loading file", wxICON_ERROR|wxOK); } // Other error catch (...) { wxMessageBox(_T("Unknown error"),_T("Error loading file"),wxICON_ERROR | wxOK); - ok = false; } // Verify loading