diff --git a/src/gui/dialogs/wml_error.cpp b/src/gui/dialogs/wml_error.cpp index 73b96b1b412c..b7d2ec365cca 100644 --- a/src/gui/dialogs/wml_error.cpp +++ b/src/gui/dialogs/wml_error.cpp @@ -171,6 +171,39 @@ namespace dialogs REGISTER_DIALOG(wml_error) +static void display_error_in_error(const std::string& title, const std::string& original_error, const std::string& error_in_error) +{ + std::string message = original_error; + message += "\n\n"; + message += _("Additionally, the following error was encountered while handling this error:"); + message += "\n\n"; + message += error_in_error; + message += "\n\n"; + message += _("Due to this subsequent error, the game will now exit."); + SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, title.c_str(), message.c_str(), nullptr); +} + +void wml_error::display(const std::string& summary, + const std::string& post_summary, + const std::vector& files, + const std::string& details) +{ + bool have_error = false; + try { + wml_error error_dialog(summary, post_summary, files, details); + try { + error_dialog.show(); + } catch(std::exception& error) { + have_error = true; + display_error_in_error("WML Error", error_dialog.report_, error.what()); + throw; + } + } catch(std::exception& error) { + if(!have_error) display_error_in_error("WML Error", summary, error.what()); + throw; + } +} + wml_error::wml_error(const std::string& summary, const std::string& post_summary, const std::vector& files, diff --git a/src/gui/dialogs/wml_error.hpp b/src/gui/dialogs/wml_error.hpp index aa682ae961ea..ed36dd7f55db 100644 --- a/src/gui/dialogs/wml_error.hpp +++ b/src/gui/dialogs/wml_error.hpp @@ -43,10 +43,7 @@ class wml_error : public modal_dialog static void display(const std::string& summary, const std::string& post_summary, const std::vector& files, - const std::string& details) - { - wml_error(summary, post_summary, files, details).show(); - } + const std::string& details); /** The display function; see @ref modal_dialog for more information. */ static void display(const std::string& summary,