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.
This commit is contained in:
Niels Martin Hansen 2010-06-20 19:03:05 +00:00
parent 363198b2fa
commit 5bd0981a72
1 changed files with 7 additions and 4 deletions

View File

@ -72,7 +72,7 @@ AssFile::~AssFile() {
} }
void AssFile::Load (const wxString &_filename,wxString charset,bool addToRecent) { void AssFile::Load (const wxString &_filename,wxString charset,bool addToRecent) {
bool ok = true; bool ok = false;
try { try {
// Try to open file // Try to open file
@ -102,6 +102,7 @@ void AssFile::Load (const wxString &_filename,wxString charset,bool addToRecent)
if (reader) { if (reader) {
reader->SetTarget(this); reader->SetTarget(this);
reader->ReadFile(_filename,charset); reader->ReadFile(_filename,charset);
ok = true;
} }
// Couldn't find a type // Couldn't find a type
@ -111,18 +112,20 @@ void AssFile::Load (const wxString &_filename,wxString charset,bool addToRecent)
// String error // String error
catch (const wchar_t *except) { catch (const wchar_t *except) {
wxMessageBox(except,_T("Error loading file"),wxICON_ERROR | wxOK); wxMessageBox(except,_T("Error loading file"),wxICON_ERROR | wxOK);
ok = false;
} }
catch (wxString except) { catch (wxString except) {
wxMessageBox(except,_T("Error loading file"),wxICON_ERROR | wxOK); 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 // Other error
catch (...) { catch (...) {
wxMessageBox(_T("Unknown error"),_T("Error loading file"),wxICON_ERROR | wxOK); wxMessageBox(_T("Unknown error"),_T("Error loading file"),wxICON_ERROR | wxOK);
ok = false;
} }
// Verify loading // Verify loading