mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-10 13:06:59 -04:00
message boxes for errors
git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@19 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
@@ -19,3 +19,31 @@ Error::~Error() {}
|
||||
String Error::what() const {
|
||||
return message;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------- : Error handling
|
||||
|
||||
// Errors for which a message box was already shown
|
||||
vector<String> previous_errors;
|
||||
String pending_error;
|
||||
DECLARE_TYPEOF_COLLECTION(String);
|
||||
|
||||
void handle_error(const String& e, bool allow_duplicate = true, bool now = true) {
|
||||
// Check duplicates
|
||||
if (!allow_duplicate) {
|
||||
FOR_EACH(pe, previous_errors) {
|
||||
if (e == pe) return;
|
||||
}
|
||||
previous_errors.push_back(e);
|
||||
}
|
||||
// Only show errors in the main thread
|
||||
if (!now || !wxThread::IsMain()) {
|
||||
pending_error = e;
|
||||
return;
|
||||
}
|
||||
// show message
|
||||
wxMessageBox(e, _("Error"), wxOK | wxICON_ERROR);
|
||||
}
|
||||
|
||||
void handle_error(const Error& e, bool allow_duplicate, bool now) {
|
||||
handle_error(e.what(), allow_duplicate, now);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user