diff --git a/include/loot/exception/cyclic_interaction_error.h b/include/loot/exception/cyclic_interaction_error.h index 6f5ba3c6..2474ea0f 100644 --- a/include/loot/exception/cyclic_interaction_error.h +++ b/include/loot/exception/cyclic_interaction_error.h @@ -34,7 +34,28 @@ namespace loot { */ class CyclicInteractionError : public std::runtime_error { public: - using std::runtime_error::runtime_error; + CyclicInteractionError(const std::string& firstPlugin, const std::string& lastPlugin, const std::string& backCycle) : + std::runtime_error("Cyclic interaction detected between plugins \"" + firstPlugin + "\" and \"" + lastPlugin + "\". Back cycle: " + backCycle), + firstPlugin_(firstPlugin), + lastPlugin_(lastPlugin), + backCycle_(backCycle) {} + + std::string getFirstPlugin() { + return firstPlugin_; + } + + std::string getLastPlugin() { + return lastPlugin_; + } + + std::string getBackCycle() { + return backCycle_; + } + +private: + const std::string firstPlugin_; + const std::string lastPlugin_; + const std::string backCycle_; }; } diff --git a/resources/l10n/template.pot b/resources/l10n/template.pot index 6236dfe2..3eeec845 100644 --- a/resources/l10n/template.pot +++ b/resources/l10n/template.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: LOOT 0.10.1\n" "Report-Msgid-Bugs-To: https://github.com/loot/loot/issues\n" -"POT-Creation-Date: 2016-11-22 19:39+0000\n" +"POT-Creation-Date: 2016-12-14 21:55+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -657,20 +657,35 @@ msgid "" "[LOOT's website](https://loot.github.io/)." msgstr "" -#: src/gui/query/metadata_query.h:79 src/gui/query/metadata_query.h:80 -msgid "(edited)" +#: src/gui/query/metadata_query.h:90 src/gui/query/metadata_query.h:91 +msgid "N/A: No masterlist present" msgstr "" -#: src/gui/query/metadata_query.h:101 +#: src/gui/query/metadata_query.h:93 src/gui/query/metadata_query.h:94 +msgid "Unknown: Git repository missing" +msgstr "" + +#: src/gui/query/metadata_query.h:117 msgid "" "A global message contains a condition that could not be evaluated. Details: " "%1%" msgstr "" -#: src/gui/query/metadata_query.h:127 src/backend/plugin/plugin_sorter.cpp:219 +#: src/gui/query/metadata_query.h:143 src/backend/plugin/plugin_sorter.cpp:217 msgid "\"%1%\" contains a condition that could not be evaluated. Details: %2%" msgstr "" +#: src/gui/query/metadata_query.h:174 src/gui/query/metadata_query.h:175 +msgid "(edited)" +msgstr "" + +#: src/gui/query/query.h:40 +msgid "" +"Oh no, something went wrong! If you've enabled debug logging in your " +"settings, you can check your LOOTDebugLog.txt (you can get to it through the " +"main menu) for more information." +msgstr "" + #: src/gui/query/sort_plugins_query.h:48 msgid "Loading plugin contents..." msgstr "" @@ -679,8 +694,10 @@ msgstr "" msgid "Sorting load order..." msgstr "" -#: src/backend/app/loot_paths.cpp:88 -msgid "Failed to get %LOCALAPPDATA% path." +#: src/gui/query/sort_plugins_query.h:83 +msgid "" +"Cyclic interaction detected between plugins \"%1%\" and \"%2%\". Back cycle: " +"%3%" msgstr "" #: src/backend/app/loot_state.cpp:124 @@ -691,108 +708,25 @@ msgstr "" msgid "Error: Settings parsing failed. %1%" msgstr "" -#: src/backend/app/loot_state.cpp:193 +#: src/backend/app/loot_state.cpp:191 msgid "Error: Game-specific settings could not be initialised. %1%" msgstr "" -#: src/backend/app/loot_state.cpp:272 -msgid "None of the supported games were detected." -msgstr "" - -#: src/backend/game/game.cpp:64 -msgid "Game path could not be detected." -msgstr "" - -#: src/backend/game/game.cpp:74 -msgid "Could not create LOOT folder for game. Details: %1%" -msgstr "" - #: src/backend/game/game_cache.cpp:119 msgid "You have not sorted your load order this session." msgstr "" -#: src/backend/game/load_order_handler.cpp:48 -msgid "Game path is not initialised." -msgstr "" - -#: src/backend/game/load_order_handler.cpp:84 -msgid "" -"libloadorder failed to create a game handle. Details could not be fetched." -msgstr "" - -#: src/backend/game/load_order_handler.cpp:87 -msgid "libloadorder failed to create a game handle. Details: %1%" -msgstr "" - -#: src/backend/game/load_order_handler.cpp:105 -msgid "" -"libloadorder failed to check if a plugin is active. Details could not be " -"fetched." -msgstr "" - -#: src/backend/game/load_order_handler.cpp:108 -msgid "libloadorder failed to check if a plugin is active. Details: %1%" -msgstr "" - -#: src/backend/game/load_order_handler.cpp:130 -msgid "" -"libloadorder failed to get the load order. Details could not be fetched." -msgstr "" - -#: src/backend/game/load_order_handler.cpp:133 -msgid "libloadorder failed to get the load order. Details: %1%" -msgstr "" - -#: src/backend/game/load_order_handler.cpp:170 -msgid "" -"libloadorder failed to set the load order. Details could not be fetched." -msgstr "" - -#: src/backend/game/load_order_handler.cpp:173 -msgid "libloadorder failed to set the load order. Details: %1%" -msgstr "" - -#: src/backend/helpers/git_helper.cpp:105 -msgid "Git operation failed. Error: %1%" -msgstr "" - -#: src/backend/helpers/git_helper.cpp:146 +#: src/backend/helpers/git_helper.cpp:145 msgid "" "An error occurred while trying to clone the remote masterlist repository." msgstr "" -#: src/backend/helpers/git_helper.cpp:195 +#: src/backend/helpers/git_helper.cpp:194 msgid "" "An error occurred while trying to update the masterlist. This could be due " "to a server-side error. Try again in a few minutes." msgstr "" -#: src/backend/helpers/helpers.cpp:81 -msgid "Unable to open \"%1%\" for CRC calculation." -msgstr "" - -#: src/backend/helpers/helpers.cpp:103 src/backend/helpers/helpers.cpp:106 -msgid "Failed to open file in its default application." -msgstr "" - -#: src/backend/metadata/condition_evaluator.cpp:173 -msgid "Invalid file path: %1%" -msgstr "" - -#: src/backend/metadata/condition_evaluator.cpp:183 -#: src/backend/metadata/condition_evaluator.cpp:223 -msgid "Invalid regex string \"%1%\": %2%" -msgstr "" - -#: src/backend/metadata/condition_grammar.h:203 -msgid "Failed to parse condition \"%1%\": expected \"%2%\" at \"%3%\"." -msgstr "" - -#: src/backend/metadata/conditional_metadata.cpp:91 -msgid "" -"Failed to parse condition \"%1%\": only partially matched expected syntax." -msgstr "" - #: src/backend/metadata/plugin_cleaning_data.cpp:89 msgid "%1% ITM record" msgid_plural "%1% ITM records" @@ -847,26 +781,12 @@ msgstr "" msgid "This plugin is incompatible with \"%1%\", but both are present." msgstr "" -#: src/backend/plugin/plugin_sorter.cpp:84 -msgid "" -"Cyclic interaction detected between plugins \"%1%\" and \"%2%\". Back cycle: " -"%3%" -msgstr "" - #: src/backend/masterlist.cpp:45 msgid "" "An error occurred while trying to read the local masterlist's version. If " "this error happens again, try deleting the \".git\" folder in %1%." msgstr "" -#: src/backend/masterlist.cpp:49 -msgid "N/A: No masterlist present" -msgstr "" - -#: src/backend/masterlist.cpp:52 -msgid "Unknown: Git repository missing" -msgstr "" - #: src/backend/masterlist.cpp:117 src/backend/masterlist.cpp:131 msgid "" "An error occurred while trying to access the local masterlist repository. If " diff --git a/src/backend/app/loot_paths.cpp b/src/backend/app/loot_paths.cpp index 60fba5f6..31148687 100644 --- a/src/backend/app/loot_paths.cpp +++ b/src/backend/app/loot_paths.cpp @@ -85,7 +85,7 @@ boost::filesystem::path LootPaths::getLocalAppDataPath() { PWSTR path; if (SHGetKnownFolderPath(FOLDERID_LocalAppData, 0, NULL, &path) != S_OK) - throw std::system_error(GetLastError(), std::system_category(), boost::locale::translate("Failed to get %LOCALAPPDATA% path.")); + throw std::system_error(GetLastError(), std::system_category(), "Failed to get %LOCALAPPDATA% path."); boost::filesystem::path localAppDataPath(FromWinWide(path)); CoTaskMemFree(path); diff --git a/src/backend/app/loot_state.cpp b/src/backend/app/loot_state.cpp index 42d79305..5d41b4de 100644 --- a/src/backend/app/loot_state.cpp +++ b/src/backend/app/loot_state.cpp @@ -186,8 +186,6 @@ void LootState::init(const std::string& cmdLineGame) { currentGame_->Init(true); // Update game path in settings object. storeGameSettings(toGameSettings(games_)); - } catch (GameDetectionError& e) { - initErrors_.push_back(e.what()); } catch (std::exception& e) { BOOST_LOG_TRIVIAL(error) << "Game-specific settings could not be initialised. " << e.what(); initErrors_.push_back((format(translate("Error: Game-specific settings could not be initialised. %1%")) % e.what()).str()); @@ -266,10 +264,10 @@ void LootState::selectGame(std::string preferredGame) { return game.IsInstalled(); }); } + // If no game can be selected, throw an exception. if (currentGame_ == end(games_)) { - BOOST_LOG_TRIVIAL(error) << "None of the supported games were detected."; - throw GameDetectionError(translate("None of the supported games were detected.")); + throw GameDetectionError("None of the supported games were detected."); } } diff --git a/src/backend/game/game.cpp b/src/backend/game/game.cpp index bbbe31dc..349a3d54 100644 --- a/src/backend/game/game.cpp +++ b/src/backend/game/game.cpp @@ -36,7 +36,6 @@ #include "loot/exception/game_detection_error.h" #include "backend/helpers/helpers.h" -using boost::locale::translate; using std::list; using std::string; using std::thread; @@ -60,8 +59,7 @@ void Game::Init(bool createFolder, const boost::filesystem::path& gameLocalAppDa BOOST_LOG_TRIVIAL(info) << "Initialising filesystem-related data for game: " << Name(); if (!this->IsInstalled()) { - BOOST_LOG_TRIVIAL(error) << "Game path could not be detected."; - throw GameDetectionError(translate("Game path could not be detected.")); + throw GameDetectionError("Game path could not be detected."); } if (createFolder) { @@ -70,8 +68,7 @@ void Game::Init(bool createFolder, const boost::filesystem::path& gameLocalAppDa if (!fs::exists(LootPaths::getLootDataPath() / FolderName())) fs::create_directories(LootPaths::getLootDataPath() / FolderName()); } catch (fs::filesystem_error& e) { - BOOST_LOG_TRIVIAL(error) << "Could not create LOOT folder for game. Details: " << e.what(); - throw FileAccessError((boost::format(translate("Could not create LOOT folder for game. Details: %1%")) % e.what()).str()); + throw FileAccessError((boost::format("Could not create LOOT folder for game. Details: %1%") % e.what()).str()); } } diff --git a/src/backend/game/load_order_handler.cpp b/src/backend/game/load_order_handler.cpp index 4730c105..e1a6a451 100644 --- a/src/backend/game/load_order_handler.cpp +++ b/src/backend/game/load_order_handler.cpp @@ -26,13 +26,11 @@ #include #include -#include #include #include "loot/exception/error_categories.h" using boost::format; -using boost::locale::translate; using std::string; namespace loot { @@ -44,8 +42,7 @@ LoadOrderHandler::~LoadOrderHandler() { void LoadOrderHandler::Init(const GameSettings& game, const boost::filesystem::path& gameLocalAppData) { if (game.GamePath().empty()) { - BOOST_LOG_TRIVIAL(error) << "Game path is not initialised."; - throw std::invalid_argument(translate("Game path is not initialised.").str()); + throw std::invalid_argument("Game path is not initialised."); } const char * gameLocalDataPath = nullptr; @@ -80,11 +77,9 @@ void LoadOrderHandler::Init(const GameSettings& game, const boost::filesystem::p string err; lo_get_error_message(&e); if (e == nullptr) { - BOOST_LOG_TRIVIAL(error) << "libloadorder failed to create a game handle. Details could not be fetched."; - err = translate("libloadorder failed to create a game handle. Details could not be fetched.").str(); + err = "libloadorder failed to create a game handle. Details could not be fetched."; } else { - BOOST_LOG_TRIVIAL(error) << "libloadorder failed to create a game handle. Details: " << e; - err = (format(translate("libloadorder failed to create a game handle. Details: %1%")) % e).str(); + err = (format("libloadorder failed to create a game handle. Details: %1%") % e).str(); } lo_cleanup(); throw std::system_error(ret, libloadorder_category(), err); @@ -101,11 +96,9 @@ bool LoadOrderHandler::IsPluginActive(const std::string& pluginName) const { string err; lo_get_error_message(&e); if (e == nullptr) { - BOOST_LOG_TRIVIAL(error) << "libloadorder failed to check if a plugin is active. Details could not be fetched."; - err = translate("libloadorder failed to check if a plugin is active. Details could not be fetched.").str(); + err = "libloadorder failed to check if a plugin is active. Details could not be fetched."; } else { - BOOST_LOG_TRIVIAL(error) << "libloadorder failed to check if a plugin is active. Details: " << e; - err = (format(translate("libloadorder failed to check if a plugin is active. Details: %1%")) % e).str(); + err = (format("libloadorder failed to check if a plugin is active. Details: %1%") % e).str(); } lo_cleanup(); throw std::system_error(ret, libloadorder_category(), err); @@ -126,11 +119,9 @@ std::vector LoadOrderHandler::GetLoadOrder() const { string err; lo_get_error_message(&e); if (e == nullptr) { - BOOST_LOG_TRIVIAL(error) << "libloadorder failed to get the load order. Details could not be fetched."; - err = translate("libloadorder failed to get the load order. Details could not be fetched.").str(); + err = "libloadorder failed to get the load order. Details could not be fetched."; } else { - BOOST_LOG_TRIVIAL(error) << "libloadorder failed to get the load order. Details: " << e; - err = (format(translate("libloadorder failed to get the load order. Details: %1%")) % e).str(); + err = (format("libloadorder failed to get the load order. Details: %1%") % e).str(); } lo_cleanup(); throw std::system_error(ret, libloadorder_category(), err); @@ -166,11 +157,9 @@ void LoadOrderHandler::SetLoadOrder(const std::vector& loadOrder) c string err; lo_get_error_message(&e); if (e == nullptr) { - BOOST_LOG_TRIVIAL(error) << "libloadorder failed to set the load order. Details could not be fetched."; - err = translate("libloadorder failed to set the load order. Details could not be fetched.").str(); + err = "libloadorder failed to set the load order. Details could not be fetched."; } else { - BOOST_LOG_TRIVIAL(error) << "libloadorder failed to set the load order. Details: " << e; - err = (format(translate("libloadorder failed to set the load order. Details: %1%")) % e).str(); + err = (format("libloadorder failed to set the load order. Details: %1%") % e).str(); } lo_cleanup(); diff --git a/src/backend/helpers/git_helper.cpp b/src/backend/helpers/git_helper.cpp index ce5e2452..553796e2 100644 --- a/src/backend/helpers/git_helper.cpp +++ b/src/backend/helpers/git_helper.cpp @@ -102,9 +102,8 @@ void GitHelper::Call(int error_code) { giterr_clear(); if (errorMessage_.empty()) - errorMessage_ = (boost::format(translate("Git operation failed. Error: %1%")) % gitError).str(); + errorMessage_ = (boost::format("Git operation failed. Error: %1%") % gitError).str(); - BOOST_LOG_TRIVIAL(error) << "Git operation failed. Error: " << gitError; throw std::system_error(error_code, libgit2_category(), errorMessage_); } diff --git a/src/backend/helpers/helpers.cpp b/src/backend/helpers/helpers.cpp index 3c6c6843..b56162a3 100644 --- a/src/backend/helpers/helpers.cpp +++ b/src/backend/helpers/helpers.cpp @@ -36,7 +36,6 @@ #include #include #include -#include #include #include @@ -54,7 +53,6 @@ # include "shlwapi.h" #endif -using boost::locale::translate; using std::string; using std::wstring; @@ -96,8 +94,7 @@ uint32_t GetCrc32(const boost::filesystem::path& filename) { return checksum; } catch (std::exception& e) { - BOOST_LOG_TRIVIAL(error) << "Unable to open \"" << filename.string() << "\" for CRC calculation."; - throw FileAccessError((boost::format(translate("Unable to open \"%1%\" for CRC calculation: %2%")) % filename.string() % e.what()).str()); + throw FileAccessError((boost::format("Unable to open \"%1%\" for CRC calculation: %2%") % filename.string() % e.what()).str()); } } @@ -117,10 +114,10 @@ void OpenInDefaultApplication(const boost::filesystem::path& file) { #ifdef _WIN32 HINSTANCE ret = ShellExecute(0, NULL, ToWinWide(file.string()).c_str(), NULL, NULL, SW_SHOWNORMAL); if ((int)ret <= 32) - throw std::system_error(GetLastError(), std::system_category(), translate("Failed to open file in its default application.")); + throw std::system_error(GetLastError(), std::system_category(), "Failed to open file in its default application."); #else if (system(("/usr/bin/xdg-open" + file.string()).c_str()) != 0) - throw std::system_error(errno, std::system_category(), translate("Failed to open file in its default application.")); + throw std::system_error(errno, std::system_category(), "Failed to open file in its default application."); #endif } diff --git a/src/backend/masterlist.cpp b/src/backend/masterlist.cpp index 7ffd2569..8188d751 100644 --- a/src/backend/masterlist.cpp +++ b/src/backend/masterlist.cpp @@ -46,10 +46,10 @@ MasterlistInfo Masterlist::GetInfo(const boost::filesystem::path& path, bool sho if (!fs::exists(path)) { BOOST_LOG_TRIVIAL(info) << "Unknown masterlist revision: No masterlist present."; - throw FileAccessError(translate("N/A: No masterlist present")); + throw FileAccessError(string("N/A: No masterlist present at ") + path.string()); } else if (!git.IsRepository(path.parent_path())) { BOOST_LOG_TRIVIAL(info) << "Unknown masterlist revision: Git repository missing."; - throw GitStateError(translate("Unknown: Git repository missing")); + throw GitStateError(string("Unknown: \"") + path.parent_path().string() + "\" is not a Git repository."); } BOOST_LOG_TRIVIAL(debug) << "Existing repository found, attempting to open it."; diff --git a/src/backend/metadata/condition_evaluator.cpp b/src/backend/metadata/condition_evaluator.cpp index 4b8d4656..b7608295 100644 --- a/src/backend/metadata/condition_evaluator.cpp +++ b/src/backend/metadata/condition_evaluator.cpp @@ -30,7 +30,6 @@ #include "loot/exception/condition_syntax_error.h" using boost::format; -using boost::locale::translate; namespace loot { ConditionEvaluator::ConditionEvaluator(Game * game) : game_(game) {} @@ -170,8 +169,7 @@ void ConditionEvaluator::validatePath(const boost::filesystem::path& path) { continue; if (component == ".." && temp.filename() == "..") { - BOOST_LOG_TRIVIAL(error) << "Invalid file path: " << path; - throw ConditionSyntaxError((format(translate("Invalid file path: %1%")) % path.string()).str()); + throw ConditionSyntaxError((format("Invalid file path: %1%") % path.string()).str()); } temp /= component; @@ -181,7 +179,7 @@ void ConditionEvaluator::validateRegex(const std::string& regexString) { try { std::regex(regexString, std::regex::ECMAScript | std::regex::icase); } catch (std::regex_error& e) { - throw ConditionSyntaxError((format(translate("Invalid regex string \"%1%\": %2%")) % regexString % e.what()).str()); + throw ConditionSyntaxError((format("Invalid regex string \"%1%\": %2%") % regexString % e.what()).str()); } } @@ -220,8 +218,7 @@ std::pair ConditionEvaluator::splitRegex(co try { reg = std::regex(filename, std::regex::ECMAScript | std::regex::icase); } catch (std::regex_error& e) { - BOOST_LOG_TRIVIAL(error) << "Invalid regex string:" << filename; - throw ConditionSyntaxError((boost::format(boost::locale::translate("Invalid regex string \"%1%\": %2%")) % filename % e.what()).str()); + throw ConditionSyntaxError((format("Invalid regex string \"%1%\": %2%") % filename % e.what()).str()); } return std::pair(parent, reg); diff --git a/src/backend/metadata/condition_grammar.h b/src/backend/metadata/condition_grammar.h index e5b6a578..2cb10d1f 100644 --- a/src/backend/metadata/condition_grammar.h +++ b/src/backend/metadata/condition_grammar.h @@ -39,7 +39,6 @@ #include #include #include -#include #include #include #include @@ -198,9 +197,7 @@ private: std::string context(errorpos, last); boost::trim(context); - BOOST_LOG_TRIVIAL(error) << "Expected \"" << what.tag << "\" at \"" << context << "\"."; - - throw ConditionSyntaxError((boost::format(boost::locale::translate("Failed to parse condition \"%1%\": expected \"%2%\" at \"%3%\".")) % condition % what.tag % context).str()); + throw ConditionSyntaxError((boost::format("Failed to parse condition \"%1%\": expected \"%2%\" at \"%3%\".") % condition % what.tag % context).str()); } boost::spirit::qi::rule expression_, compound_, condition_, function_; diff --git a/src/backend/metadata/conditional_metadata.cpp b/src/backend/metadata/conditional_metadata.cpp index 1ffc3fb2..4876d39d 100644 --- a/src/backend/metadata/conditional_metadata.cpp +++ b/src/backend/metadata/conditional_metadata.cpp @@ -30,8 +30,6 @@ #include "backend/game/game.h" #include "backend/metadata/condition_grammar.h" -using boost::locale::translate; -using std::exception; using std::string; namespace loot { @@ -79,19 +77,12 @@ bool ConditionalMetadata::ParseCondition(Game * game) const { boost::spirit::qi::space_type skipper; string::const_iterator begin = condition_.begin(); string::const_iterator end = condition_.end(); - bool parseResult; bool evaluation; - try { - bool parseResult = boost::spirit::qi::phrase_parse(begin, end, grammar, skipper, evaluation); - } catch (exception& e) { - BOOST_LOG_TRIVIAL(error) << "Failed to evaluate condition \"" << condition_ << "\": " << e.what(); - throw; - } + bool parseResult = boost::spirit::qi::phrase_parse(begin, end, grammar, skipper, evaluation); if (!parseResult || begin != end) { - BOOST_LOG_TRIVIAL(error) << "Failed to parse condition \"" << condition_ << "\": only partially matched expected syntax."; - throw ConditionSyntaxError((boost::format(translate("Failed to parse condition \"%1%\": only partially matched expected syntax.")) % condition_).str()); + throw ConditionSyntaxError((boost::format("Failed to parse condition \"%1%\": only partially matched expected syntax.") % condition_).str()); } return evaluation; diff --git a/src/backend/plugin/plugin_sorter.cpp b/src/backend/plugin/plugin_sorter.cpp index cf814c31..d1b9beec 100644 --- a/src/backend/plugin/plugin_sorter.cpp +++ b/src/backend/plugin/plugin_sorter.cpp @@ -79,9 +79,7 @@ public: } backCycle.erase(backCycle.length() - 2); - BOOST_LOG_TRIVIAL(error) << "Cyclic interaction detected between plugins \"" << graph[source].Name() << "\" and \"" << graph[target].Name() << "\". Back cycle: " << backCycle; - - throw CyclicInteractionError((boost::format(boost::locale::translate("Cyclic interaction detected between plugins \"%1%\" and \"%2%\". Back cycle: %3%")) % graph[source].Name() % graph[target].Name() % backCycle).str()); + throw CyclicInteractionError(graph[source].Name(), graph[target].Name(), backCycle); } private: diff --git a/src/gui/query/get_game_data_query.h b/src/gui/query/get_game_data_query.h index 52e2405a..1b4f5d37 100644 --- a/src/gui/query/get_game_data_query.h +++ b/src/gui/query/get_game_data_query.h @@ -106,22 +106,6 @@ private: } } - YAML::Node convertMasterlistMetadata() { - YAML::Node masterlistNode; - try { - MasterlistInfo info = state_.getCurrentGame().GetMasterlist().GetInfo(state_.getCurrentGame().MasterlistPath(), true); - addSuffixIfModified(info); - - masterlistNode["revision"] = info.revision_id; - masterlistNode["date"] = info.revision_date; - } catch (std::exception &e) { - masterlistNode["revision"] = e.what(); - masterlistNode["date"] = e.what(); - } - - return masterlistNode; - } - static std::vector toEditorMessages(std::vector messages, const LanguageCode language) { std::vector list; @@ -190,7 +174,7 @@ private: // ID the game using its folder value. gameNode["folder"] = state_.getCurrentGame().FolderName(); - gameNode["masterlist"] = convertMasterlistMetadata(); + gameNode["masterlist"] = getMasterlistInfo(); gameNode["globalMessages"] = getGeneralMessages(); gameNode["bashTags"] = state_.getCurrentGame().GetMasterlist().BashTags(); diff --git a/src/gui/query/metadata_query.h b/src/gui/query/metadata_query.h index f7eb4209..bf212f74 100644 --- a/src/gui/query/metadata_query.h +++ b/src/gui/query/metadata_query.h @@ -31,6 +31,8 @@ along with LOOT. If not, see #include "backend/game/game.h" #include "backend/plugin/plugin.h" #include "gui/query/query.h" +#include "loot/exception/file_access_error.h" +#include "loot/exception/git_state_error.h" namespace loot { class MetadataQuery : public Query { @@ -74,11 +76,25 @@ protected: } } - void addSuffixIfModified(MasterlistInfo& info) { - if (info.is_modified) { - info.revision_date += " " + boost::locale::translate("(edited)").str(); - info.revision_id += " " + boost::locale::translate("(edited)").str(); + YAML::Node getMasterlistInfo() { + using boost::locale::translate; + + YAML::Node masterlistNode; + try { + MasterlistInfo info = state_.getCurrentGame().GetMasterlist().GetInfo(state_.getCurrentGame().MasterlistPath(), true); + addSuffixIfModified(info); + + masterlistNode["revision"] = info.revision_id; + masterlistNode["date"] = info.revision_date; + } catch (FileAccessError &) { + masterlistNode["revision"] = translate("N/A: No masterlist present").str(); + masterlistNode["date"] = translate("N/A: No masterlist present").str(); + } catch (GitStateError &) { + masterlistNode["revision"] = translate("Unknown: Git repository missing").str(); + masterlistNode["date"] = translate("Unknown: Git repository missing").str(); } + + return masterlistNode; } private: @@ -153,6 +169,13 @@ private: return pluginNode; } + void addSuffixIfModified(MasterlistInfo& info) { + if (info.is_modified) { + info.revision_date += " " + boost::locale::translate("(edited)").str(); + info.revision_id += " " + boost::locale::translate("(edited)").str(); + } + } + LootState& state_; }; } diff --git a/src/gui/query/query.h b/src/gui/query/query.h index 18fa4692..7fde1510 100644 --- a/src/gui/query/query.h +++ b/src/gui/query/query.h @@ -25,6 +25,7 @@ along with LOOT. If not, see #ifndef LOOT_GUI_QUERY_QUERY #define LOOT_GUI_QUERY_QUERY +#include #include #include @@ -36,7 +37,7 @@ public: callback->Success(executeLogic()); } catch (std::exception &e) { BOOST_LOG_TRIVIAL(error) << e.what(); - callback->Failure(-1, e.what()); + callback->Failure(-1, boost::locale::translate("Oh no, something went wrong! If you've enabled debug logging in your settings, you can check your LOOTDebugLog.txt (you can get to it through the main menu) for more information.").str()); } } diff --git a/src/gui/query/sort_plugins_query.h b/src/gui/query/sort_plugins_query.h index ea3f777a..9029e496 100644 --- a/src/gui/query/sort_plugins_query.h +++ b/src/gui/query/sort_plugins_query.h @@ -79,7 +79,9 @@ private: plugins = sorter.Sort(state_.getCurrentGame(), state_.getLanguage().GetCode()); } catch (CyclicInteractionError& e) { BOOST_LOG_TRIVIAL(error) << "Failed to sort plugins. Details: " << e.what(); - state_.getCurrentGame().AppendMessage(Message(MessageType::error, e.what())); + state_.getCurrentGame().AppendMessage(Message(MessageType::error, + (boost::format(boost::locale::translate("Cyclic interaction detected between plugins \"%1%\" and \"%2%\". Back cycle: %3%")) + % e.getFirstPlugin() % e.getLastPlugin() % e.getBackCycle()).str())); } catch (std::exception& e) { BOOST_LOG_TRIVIAL(error) << "Failed to sort plugins. Details: " << e.what(); } diff --git a/src/gui/query/update_masterlist_query.h b/src/gui/query/update_masterlist_query.h index 366b9517..76468d28 100644 --- a/src/gui/query/update_masterlist_query.h +++ b/src/gui/query/update_masterlist_query.h @@ -60,7 +60,7 @@ private: std::string generateJsonResponse() { YAML::Node gameMetadata; - storeMasterlistMetadata(gameMetadata); + gameMetadata["masterlist"] = getMasterlistInfo(); // Store bash tags in case they have changed. gameMetadata["bashTags"] = game_.GetMasterlist().BashTags(); @@ -75,19 +75,6 @@ private: return JSON::stringify(gameMetadata); } - void storeMasterlistMetadata(YAML::Node& gameMetadata) { - try { - MasterlistInfo info = game_.GetMasterlist().GetInfo(game_.MasterlistPath(), true); - addSuffixIfModified(info); - - gameMetadata["masterlist"]["revision"] = info.revision_id; - gameMetadata["masterlist"]["date"] = info.revision_date; - } catch (std::exception& e) { - gameMetadata["masterlist"]["revision"] = e.what(); - gameMetadata["masterlist"]["date"] = e.what(); - } - } - YAML::Node generateDerivedMetadata(const Plugin& plugin) { YAML::Node pluginNode;