Get wxMessageBox out of AssFile

This commit is contained in:
Thomas Goyne 2012-10-11 20:18:47 -07:00
parent 33dd0abc7f
commit a53432736c
4 changed files with 17 additions and 19 deletions

View File

@ -82,10 +82,7 @@ void AssFile::Load(const wxString &_filename, wxString charset, bool addToRecent
try { try {
// Get proper format reader // Get proper format reader
const SubtitleFormat *reader = SubtitleFormat::GetReader(_filename); const SubtitleFormat *reader = SubtitleFormat::GetReader(_filename);
if (!reader) { if (!reader) throw "Unknown file type";
wxMessageBox("Unknown file type","Error loading file",wxOK | wxICON_ERROR | wxCENTER);
return;
}
AssFile temp; AssFile temp;
reader->ReadFile(&temp, _filename, charset); reader->ReadFile(&temp, _filename, charset);
@ -112,16 +109,6 @@ void AssFile::Load(const wxString &_filename, wxString charset, bool addToRecent
catch (agi::UserCancelException const&) { catch (agi::UserCancelException const&) {
return; return;
} }
// Real exception
catch (agi::Exception &e) {
wxMessageBox(lagi_wxString(e.GetChainedMessage()), "Error loading file", wxOK | wxICON_ERROR | wxCENTER);
return;
}
// Other error
catch (...) {
wxMessageBox("Unknown error","Error loading file",wxOK | wxICON_ERROR | wxCENTER);
return;
}
// Set general data // Set general data
loaded = true; loaded = true;

View File

@ -48,13 +48,9 @@
#include <libaegisub/signal.h> #include <libaegisub/signal.h>
class FrameRate;
class AssDialogue; class AssDialogue;
class AssStyle; class AssStyle;
class AssAttachment; class AssAttachment;
class AssDialogueBlock;
class AssDialogueBlockOverride;
class AssDialogueBlockPlain;
class AssEntry; class AssEntry;
typedef std::list<AssEntry*>::iterator entryIter; typedef std::list<AssEntry*>::iterator entryIter;

View File

@ -600,7 +600,19 @@ void DialogStyleManager::OnCurrentImport() {
try { try {
temp.Load(filename, "", false); temp.Load(filename, "", false);
} }
catch (const char *err) {
wxMessageBox(err, "Error", wxOK | wxICON_ERROR | wxCENTER, this);
return;
}
catch (wxString const& err) {
wxMessageBox(err, "Error", wxOK | wxICON_ERROR | wxCENTER, this);
return;
}
catch (agi::Exception const& err) {
wxMessageBox(lagi_wxString(err.GetChainedMessage()), "Error", wxOK | wxICON_ERROR | wxCENTER, this);
}
catch (...) { catch (...) {
wxMessageBox("Unknown error", "Error", wxOK | wxICON_ERROR | wxCENTER, this);
return; return;
} }

View File

@ -436,13 +436,16 @@ void FrameMain::LoadSubtitles(wxString filename,wxString charset) {
return; return;
} }
catch (const char *err) { catch (const char *err) {
wxMessageBox(wxString(err), "Error", wxOK | wxICON_ERROR | wxCENTER, this); wxMessageBox(err, "Error", wxOK | wxICON_ERROR | wxCENTER, this);
return; return;
} }
catch (wxString const& err) { catch (wxString const& err) {
wxMessageBox(err, "Error", wxOK | wxICON_ERROR | wxCENTER, this); wxMessageBox(err, "Error", wxOK | wxICON_ERROR | wxCENTER, this);
return; return;
} }
catch (agi::Exception const& err) {
wxMessageBox(lagi_wxString(err.GetChainedMessage()), "Error", wxOK | wxICON_ERROR | wxCENTER, this);
}
catch (...) { catch (...) {
wxMessageBox("Unknown error", "Error", wxOK | wxICON_ERROR | wxCENTER, this); wxMessageBox("Unknown error", "Error", wxOK | wxICON_ERROR | wxCENTER, this);
return; return;