diff --git a/src/addon/manager_ui.cpp b/src/addon/manager_ui.cpp index 124fa3cb127..9e4401e1608 100644 --- a/src/addon/manager_ui.cpp +++ b/src/addon/manager_ui.cpp @@ -1067,7 +1067,7 @@ bool addons_manager_ui(CVideo& v, const std::string& remote_address) gui2::show_error_message(v, vgettext("A local file with add-on publishing information could not be read.\n\nFile: $path\nError message: $msg", symbols)); - } catch(twml_exception& e) { + } catch(wml_exception& e) { e.show(v); } catch(const addons_client::user_exit&) { LOG_AC << "initial connection canceled by user\n"; @@ -1277,7 +1277,7 @@ bool ad_hoc_addon_fetch_session(CVideo& v, const std::vector& addon gui2::show_error_message(v, vgettext("A local file with add-on publishing information could not be read.\n\nFile: $path\nError message: $msg", symbols)); - } catch(twml_exception& e) { + } catch(wml_exception& e) { e.show(v); } catch(const addons_client::user_exit&) { LOG_AC << "initial connection canceled by user\n"; diff --git a/src/editor/controller/editor_controller.cpp b/src/editor/controller/editor_controller.cpp index e12348859dd..c62dcc16401 100644 --- a/src/editor/controller/editor_controller.cpp +++ b/src/editor/controller/editor_controller.cpp @@ -179,7 +179,7 @@ EXIT_STATUS editor_controller::main_loop() } catch (editor_exception& e) { gui2::show_transient_message(gui().video(), _("Fatal error"), e.what()); return EXIT_ERROR; - } catch (twml_exception& e) { + } catch (wml_exception& e) { e.show(gui().video()); } return quit_mode_; @@ -194,7 +194,7 @@ void editor_controller::do_screenshot(const std::string& screenshot_filename /* if (!gui().screenshot(screenshot_filename,true)) { ERR_ED << "Screenshot creation failed!\n"; } - } catch (twml_exception& e) { + } catch (wml_exception& e) { e.show(gui().video()); } } diff --git a/src/editor/map/editor_map.cpp b/src/editor/map/editor_map.cpp index a85ff9b623b..ace9d06e63e 100644 --- a/src/editor/map/editor_map.cpp +++ b/src/editor/map/editor_map.cpp @@ -59,7 +59,7 @@ editor_map editor_map::from_string(const config& terrain_cfg, const std::string& return editor_map(terrain_cfg, data); } catch (incorrect_map_format_error& e) { throw wrap_exc("format", e.message, ""); - } catch (twml_exception& e) { + } catch (wml_exception& e) { throw wrap_exc("wml", e.user_message, ""); } catch (config::error& e) { throw wrap_exc("config", e.message, ""); diff --git a/src/game_events/action_wml.cpp b/src/game_events/action_wml.cpp index b0042f25710..c36e7ea781a 100644 --- a/src/game_events/action_wml.cpp +++ b/src/game_events/action_wml.cpp @@ -572,7 +572,7 @@ WML_HANDLER_FUNCTION(replace_map,, cfg) const std::string log_map_name = cfg["map"].empty() ? cfg["file"] : std::string("from inline data"); lg::wml_error() << "replace_map: Unable to load map " << log_map_name << std::endl; return; - } catch(twml_exception& e) { + } catch(wml_exception& e) { e.show(resources::screen->video()); return; } @@ -834,7 +834,7 @@ WML_HANDLER_FUNCTION(terrain_mask,, cfg) } catch(incorrect_map_format_error&) { ERR_NG << "terrain mask is in the incorrect format, and couldn't be applied" << std::endl; return; - } catch(twml_exception& e) { + } catch(wml_exception& e) { e.show(resources::screen->video()); return; } diff --git a/src/game_initialization/create_engine.cpp b/src/game_initialization/create_engine.cpp index 3827bdbf09e..b2b4163c5e1 100644 --- a/src/game_initialization/create_engine.cpp +++ b/src/game_initialization/create_engine.cpp @@ -169,7 +169,7 @@ void scenario::set_metadata() data_["description"] = _("Map could not be loaded: ") + e.message; ERR_CF << "map could not be loaded: " << e.message << '\n'; - } catch(twml_exception& e) { + } catch(wml_exception& e) { data_["description"] = _("Map could not be loaded."); ERR_CF << "map could not be loaded: " << e.dev_message << '\n'; @@ -1051,7 +1051,7 @@ void create_engine::init_all_levels() e.message; ERR_CF << "map could not be loaded: " << e.message << '\n'; - } catch (twml_exception&) { + } catch (wml_exception&) { add_map = false; dep_index_offset++; } diff --git a/src/game_initialization/multiplayer_lobby.cpp b/src/game_initialization/multiplayer_lobby.cpp index fd6bdfe6fc1..4ce478848d3 100644 --- a/src/game_initialization/multiplayer_lobby.cpp +++ b/src/game_initialization/multiplayer_lobby.cpp @@ -625,7 +625,7 @@ void gamebrowser::populate_game_item_map_info(gamebrowser::game_item & item, con } catch (incorrect_map_format_error &e) { ERR_CF << "illegal map: " << e.message << '\n'; verified = false; - } catch(twml_exception& e) { + } catch(wml_exception& e) { ERR_CF << "map could not be loaded: " << e.dev_message << '\n'; verified = false; } diff --git a/src/game_initialization/playcampaign.cpp b/src/game_initialization/playcampaign.cpp index 322f791276b..372f9c1d3a4 100644 --- a/src/game_initialization/playcampaign.cpp +++ b/src/game_initialization/playcampaign.cpp @@ -306,7 +306,7 @@ LEVEL_RESULT campaign_controller::play_game() } catch(config::error& e) { gui2::show_error_message(video_, _("Error while reading the WML: ") + e.message); return LEVEL_RESULT::QUIT; - } catch(twml_exception& e) { + } catch(wml_exception& e) { e.show(video_); return LEVEL_RESULT::QUIT; } diff --git a/src/game_initialization/singleplayer.cpp b/src/game_initialization/singleplayer.cpp index ad6b4b3e82a..2f589dbf4d1 100644 --- a/src/game_initialization/singleplayer.cpp +++ b/src/game_initialization/singleplayer.cpp @@ -63,7 +63,7 @@ bool enter_create_mode(CVideo& video, const config& game_config, saved_game& sta try { dlg.show(video); - } catch(twml_exception& e) { + } catch(wml_exception& e) { e.show(video); return false; } diff --git a/src/game_launcher.cpp b/src/game_launcher.cpp index 3457f760c21..ad2e028f1bc 100644 --- a/src/game_launcher.cpp +++ b/src/game_launcher.cpp @@ -59,7 +59,7 @@ #include "util.hpp" // for lexical_cast_default #include "video.hpp" // for CVideo #include "wesnothd_connection_error.hpp" -#include "wml_exception.hpp" // for twml_exception +#include "wml_exception.hpp" // for wml_exception #include // for copy, max, min, stable_sort #include // for optional @@ -531,7 +531,7 @@ int game_launcher::unit_test() if (!(res == LEVEL_RESULT::VICTORY) || lg::broke_strict()) { return 1; } - } catch(twml_exception& e) { + } catch(wml_exception& e) { std::cerr << "Caught WML Exception:" << e.dev_message << std::endl; return 1; } @@ -558,7 +558,7 @@ int game_launcher::unit_test() std::cerr << "Observed failure on replay" << std::endl; return 4; } - } catch(twml_exception& e) { + } catch(wml_exception& e) { std::cerr << "WML Exception while playing replay: " << e.dev_message << std::endl; return 4; //failed with an error during the replay } @@ -652,7 +652,7 @@ bool game_launcher::load_game() gui2::show_error_message(video(), _("The file you have tried to load is corrupt: '") + e.message + '\''); } return false; - } catch(twml_exception& e) { + } catch(wml_exception& e) { e.show(video()); return false; } catch(filesystem::io_exception& e) { @@ -876,7 +876,7 @@ bool game_launcher::play_multiplayer(mp_selection res) } catch (savegame::load_game_exception & e) { load_data_.reset(new savegame::load_game_metadata(std::move(e.data_))); //this will make it so next time through the title screen loop, this game is loaded - } catch(twml_exception& e) { + } catch(wml_exception& e) { e.show(video()); } catch (game::error & e) { std::cerr << "caught game::error...\n"; @@ -965,7 +965,7 @@ void game_launcher::launch_game(RELOAD_GAME_DATA reload) } catch (savegame::load_game_exception &e) { load_data_.reset(new savegame::load_game_metadata(std::move(e.data_))); //this will make it so next time through the title screen loop, this game is loaded - } catch(twml_exception& e) { + } catch(wml_exception& e) { e.show(video()); } catch(mapgen_exception& e) { gui2::show_error_message(video(), _("Map generator error: ") + e.message); @@ -981,7 +981,7 @@ void game_launcher::play_replay() } catch (savegame::load_game_exception &e) { load_data_.reset(new savegame::load_game_metadata(std::move(e.data_))); //this will make it so next time through the title screen loop, this game is loaded - } catch(twml_exception& e) { + } catch(wml_exception& e) { e.show(video()); } } diff --git a/src/gui/dialogs/lobby/data.cpp b/src/gui/dialogs/lobby/data.cpp index 2e516b12457..1f98f1c68e9 100644 --- a/src/gui/dialogs/lobby/data.cpp +++ b/src/gui/dialogs/lobby/data.cpp @@ -299,7 +299,7 @@ game_info::game_info(const config& game, const config& game_config, const std::v } catch(incorrect_map_format_error& e) { ERR_CF << "illegal map: " << e.message << std::endl; verified = false; - } catch(twml_exception& e) { + } catch(wml_exception& e) { ERR_CF << "map could not be loaded: " << e.dev_message << '\n'; verified = false; } diff --git a/src/gui/widgets/window.cpp b/src/gui/widgets/window.cpp index ef312a12a5f..c2999ca6e51 100644 --- a/src/gui/widgets/window.cpp +++ b/src/gui/widgets/window.cpp @@ -1037,7 +1037,7 @@ void twindow::layout() << maximum_width << ',' << maximum_height << " screen size " << settings::screen_width << ',' << settings::screen_height << '.'; - throw twml_exception(_("Failed to show a dialog, " + throw wml_exception(_("Failed to show a dialog, " "which doesn't fit on the screen."), sstr.str()); } @@ -1074,7 +1074,7 @@ void twindow::layout() << settings::screen_width << ',' << settings::screen_height << '.'; - throw twml_exception(_("Failed to show a dialog, " + throw wml_exception(_("Failed to show a dialog, " "which doesn't fit on the screen."), sstr.str()); } diff --git a/src/serialization/schema_validator.cpp b/src/serialization/schema_validator.cpp index b202dec8ea3..f00f20739cb 100644 --- a/src/serialization/schema_validator.cpp +++ b/src/serialization/schema_validator.cpp @@ -38,7 +38,7 @@ static std::string at(const std::string & file, int line){ static void print_output(const std::string & message,bool flag_exception = false ){ #ifndef VALIDATION_ERRORS_LOG if(flag_exception){ - throw twml_exception("Validation error occured",message); + throw wml_exception("Validation error occured",message); }else{ ERR_VL << message; } diff --git a/src/tests/gui/test_gui2.cpp b/src/tests/gui/test_gui2.cpp index aa5d9cd2542..3ffd914b147 100644 --- a/src/tests/gui/test_gui2.cpp +++ b/src/tests/gui/test_gui2.cpp @@ -198,7 +198,7 @@ namespace { exception = "gui2::tlayout_exception_width_resize_failed"; } catch(gui2::tlayout_exception_height_resize_failed&) { exception = "gui2::tlayout_exception_height_resize_failed"; - } catch(twml_exception& e) { + } catch(wml_exception& e) { exception = e.dev_message; } catch(std::exception& e) { exception = e.what(); @@ -240,7 +240,7 @@ namespace { exception = "gui2::tlayout_exception_width_resize_failed"; } catch(gui2::tlayout_exception_height_resize_failed&) { exception = "gui2::tlayout_exception_height_resize_failed"; - } catch(twml_exception& e) { + } catch(wml_exception& e) { exception = e.dev_message; } catch(std::exception& e) { exception = e.what(); @@ -287,7 +287,7 @@ namespace { exception = "gui2::tlayout_exception_width_resize_failed"; } catch(gui2::tlayout_exception_height_resize_failed&) { exception = "gui2::tlayout_exception_height_resize_failed"; - } catch(twml_exception& e) { + } catch(wml_exception& e) { exception = e.dev_message; } catch(std::exception& e) { exception = e.what(); @@ -512,7 +512,7 @@ BOOST_AUTO_TEST_CASE(test_make_test_fake) try { gui2::tmessage dlg("title", "message", true, false); dlg.show(video, 1); - } catch(twml_exception& e) { + } catch(wml_exception& e) { BOOST_CHECK(e.user_message == _("Failed to show a dialog, " "which doesn't fit on the screen.")); return; diff --git a/src/utils/make_enum.hpp b/src/utils/make_enum.hpp index 2b1fb85eb1f..e596d74c95b 100644 --- a/src/utils/make_enum.hpp +++ b/src/utils/make_enum.hpp @@ -69,7 +69,7 @@ * * It is recommended to use MAKE_ENUM types with the built-in versions of * lexical_cast or lexical_cast_default provided by Wesnoth (see util.hpp). - * However, if you do not want twml_exception to be thrown under any + * However, if you do not want wml_exception to be thrown under any * circumstances, use the string_to_enumname functions instead. * * See src/tests/test_make_enum.cpp for example code. diff --git a/src/wesnoth.cpp b/src/wesnoth.cpp index dd7b058dba3..f06cf44de86 100644 --- a/src/wesnoth.cpp +++ b/src/wesnoth.cpp @@ -57,7 +57,7 @@ #include "video.hpp" // for CVideo #include "wesconfig.h" // for PACKAGE #include "widgets/button.hpp" // for button -#include "wml_exception.hpp" // for twml_exception +#include "wml_exception.hpp" // for wml_exception #ifdef _WIN32 #include "log_windows.hpp" @@ -1074,7 +1074,7 @@ int main(int argc, char** argv) std::cerr << "caught return_to_play_side_exception, please report this bug (quitting)\n"; } catch(quit_game_exception&) { std::cerr << "caught quit_game_exception (quitting)\n"; - } catch(twml_exception& e) { + } catch(wml_exception& e) { std::cerr << "WML exception:\nUser message: " << e.user_message << "\nDev message: " << e.dev_message << '\n'; error_exit(1); diff --git a/src/wml_exception.cpp b/src/wml_exception.cpp index b1a8896f5ec..0be1aad48ee 100644 --- a/src/wml_exception.cpp +++ b/src/wml_exception.cpp @@ -30,7 +30,7 @@ static lg::log_domain log_engine("engine"); #define WRN_NG LOG_STREAM(warn, log_engine) -void wml_exception( +void throw_wml_exception( const char* cond , const char* file , const int line @@ -51,10 +51,10 @@ void wml_exception( sstr << " Extra development information: " << dev_message; } - throw twml_exception(message, sstr.str()); + throw wml_exception(message, sstr.str()); } -void twml_exception::show(CVideo &video) +void wml_exception::show(CVideo &video) { std::ostringstream sstr; diff --git a/src/wml_exception.hpp b/src/wml_exception.hpp index 09d323a0021..4556b3c0830 100644 --- a/src/wml_exception.hpp +++ b/src/wml_exception.hpp @@ -43,14 +43,14 @@ class CVideo; #define VALIDATE(cond, message) \ do { \ if(!(cond)) { \ - wml_exception(#cond, __FILE__, __LINE__, __func__, message); \ + throw_wml_exception(#cond, __FILE__, __LINE__, __func__, message); \ } \ } while(0) #define VALIDATE_WITH_DEV_MESSAGE(cond, message, dev_message) \ do { \ if(!(cond)) { \ - wml_exception(#cond \ + throw_wml_exception(#cond \ , __FILE__ \ , __LINE__ \ , __func__ \ @@ -61,12 +61,12 @@ class CVideo; #define FAIL(message) \ do { \ - wml_exception(nullptr, __FILE__, __LINE__, __func__, message); \ + throw_wml_exception(nullptr, __FILE__, __LINE__, __func__, message); \ } while(0) #define FAIL_WITH_DEV_MESSAGE(message, dev_message) \ do { \ - wml_exception(nullptr \ + throw_wml_exception(nullptr \ , __FILE__ \ , __LINE__ \ , __func__ \ @@ -83,7 +83,7 @@ class CVideo; * @param function The function in which the test failed. * @param message The translated message to show the user. */ -NORETURN void wml_exception( +NORETURN void throw_wml_exception( const char* cond , const char* file , int line @@ -92,16 +92,16 @@ NORETURN void wml_exception( , const std::string& dev_message = ""); /** Helper class, don't construct this directly. */ -struct twml_exception +struct wml_exception : public lua_jailbreak_exception { - twml_exception(const std::string& user_msg, const std::string& dev_msg) + wml_exception(const std::string& user_msg, const std::string& dev_msg) : user_message(user_msg) , dev_message(dev_msg) { } - ~twml_exception() throw() {} + ~wml_exception() throw() {} /** * The message for the user explaining what went wrong. This message can @@ -123,7 +123,7 @@ struct twml_exception */ void show(CVideo& video); private: - IMPLEMENT_LUA_JAILBREAK_EXCEPTION(twml_exception) + IMPLEMENT_LUA_JAILBREAK_EXCEPTION(wml_exception) }; /**