1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-24 22:14:36 +02:00

Read error message from translate.json

This commit is contained in:
nordsoft 2022-09-23 15:20:11 +04:00
parent e74890c4b1
commit 8f6f9707a6
3 changed files with 6 additions and 5 deletions

View File

@ -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" :

View File

@ -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<const std::string, const std::string>;
using ModList = std::list<StringPair>;
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();

View File

@ -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)