From 8f6f9707a64898680913e6df10ab93dc5280505e Mon Sep 17 00:00:00 2001 From: nordsoft Date: Fri, 23 Sep 2022 15:20:11 +0400 Subject: [PATCH] Read error message from translate.json --- config/translate.json | 3 ++- lib/CModHandler.h | 4 +--- server/CGameHandler.cpp | 4 +++- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/config/translate.json b/config/translate.json index ba797d4d9..9d12a600b 100644 --- a/config/translate.json +++ b/config/translate.json @@ -31,7 +31,8 @@ { "errors" : { - "existingProcess" : "Another vcmiserver process is running, please terminate it first" + "existingProcess" : "Another vcmiserver process is running, please terminate it first", + "modsIncompatibility" : "Mods are required to load game:" } }, "systemOptions" : diff --git a/lib/CModHandler.h b/lib/CModHandler.h index 8b1f5ad02..d951334d8 100644 --- a/lib/CModHandler.h +++ b/lib/CModHandler.h @@ -276,18 +276,16 @@ class DLL_LINKAGE CModHandler void loadOneMod(std::string modName, std::string parent, const JsonNode & modSettings, bool enableMods); public: - class DLL_LINKAGE Incompatibility: public std::logic_error + class DLL_LINKAGE Incompatibility: public std::exception { public: using StringPair = std::pair; using ModList = std::list; Incompatibility(ModList && _missingMods): - std::logic_error("Mods are required to load game"), missingMods(std::move(_missingMods)) { std::ostringstream _ss; - _ss << std::logic_error::what() << std::endl; for(auto & m : missingMods) _ss << m.first << ' ' << m.second << std::endl; message = _ss.str(); diff --git a/server/CGameHandler.cpp b/server/CGameHandler.cpp index 8e9641135..86f2c7175 100644 --- a/server/CGameHandler.cpp +++ b/server/CGameHandler.cpp @@ -2987,7 +2987,9 @@ bool CGameHandler::load(const std::string & filename) catch(const CModHandler::Incompatibility & e) { logGlobal->error("Failed to load game: %s", e.what()); - lobby->announceMessage(e.what()); + auto errorMsg = VLC->generaltexth->localizedTexts["server"]["errors"]["modsIncompatibility"].String() + '\n'; + errorMsg += e.what(); + lobby->announceMessage(errorMsg); return false; } catch(const std::exception & e)