Rename error class to Error

This commit is contained in:
Oliver Hamlet
2016-07-13 20:47:22 +01:00
parent 4b6de8ab83
commit 36991f683b
24 changed files with 140 additions and 140 deletions
+23 -23
View File
@@ -41,20 +41,20 @@
#include <boost/filesystem/fstream.hpp>
#include <boost/log/core.hpp>
const unsigned int loot_ok = loot::error::ok;
const unsigned int loot_error_liblo_error = loot::error::liblo_error;
const unsigned int loot_error_file_write_fail = loot::error::path_write_fail;
const unsigned int loot_error_parse_fail = loot::error::path_read_fail;
const unsigned int loot_error_condition_eval_fail = loot::error::condition_eval_fail;
const unsigned int loot_error_regex_eval_fail = loot::error::regex_eval_fail;
const unsigned int loot_error_no_mem = loot::error::no_mem;
const unsigned int loot_error_invalid_args = loot::error::invalid_args;
const unsigned int loot_error_no_tag_map = loot::error::no_tag_map;
const unsigned int loot_error_path_not_found = loot::error::path_not_found;
const unsigned int loot_error_no_game_detected = loot::error::no_game_detected;
const unsigned int loot_error_git_error = loot::error::git_error;
const unsigned int loot_error_windows_error = loot::error::windows_error;
const unsigned int loot_error_sorting_error = loot::error::sorting_error;
const unsigned int loot_ok = loot::Error::ok;
const unsigned int loot_error_liblo_error = loot::Error::liblo_error;
const unsigned int loot_error_file_write_fail = loot::Error::path_write_fail;
const unsigned int loot_error_parse_fail = loot::Error::path_read_fail;
const unsigned int loot_error_condition_eval_fail = loot::Error::condition_eval_fail;
const unsigned int loot_error_regex_eval_fail = loot::Error::regex_eval_fail;
const unsigned int loot_error_no_mem = loot::Error::no_mem;
const unsigned int loot_error_invalid_args = loot::Error::invalid_args;
const unsigned int loot_error_no_tag_map = loot::Error::no_tag_map;
const unsigned int loot_error_path_not_found = loot::Error::path_not_found;
const unsigned int loot_error_no_game_detected = loot::Error::no_game_detected;
const unsigned int loot_error_git_error = loot::Error::git_error;
const unsigned int loot_error_windows_error = loot::Error::windows_error;
const unsigned int loot_error_sorting_error = loot::Error::sorting_error;
const unsigned int loot_return_max = loot_error_sorting_error;
// The following are the games identifiers used by the API.
@@ -89,13 +89,13 @@ const unsigned int loot_needs_cleaning_unknown = 2;
std::string extMessageStr;
unsigned int c_error(const loot::error& e) {
unsigned int c_error(const loot::Error& e) {
extMessageStr = e.what();
return e.code();
}
unsigned int c_error(const unsigned int code, const std::string& what) {
return c_error(loot::error(code, what.c_str()));
return c_error(loot::Error(code, what.c_str()));
}
//////////////////////////////
@@ -200,7 +200,7 @@ LOOT_API unsigned int loot_create_db(loot_db ** const db,
*db = new loot_db(clientGame, game_path, game_local_path);
}
catch (loot::error& e) {
catch (loot::Error& e) {
return c_error(e);
}
catch (std::bad_alloc& e) {
@@ -303,7 +303,7 @@ LOOT_API unsigned int loot_eval_lists(loot_db * const db, const unsigned int lan
temp.EvalAllConditions(*db, language);
userTemp.EvalAllConditions(*db, language);
}
catch (loot::error& e) {
catch (loot::Error& e) {
return c_error(e);
}
db->GetMasterlist() = temp;
@@ -335,7 +335,7 @@ LOOT_API unsigned int loot_sort_plugins(loot_db * const db,
db->setPluginNames(sorter.Sort(*db, loot::Language::english));
}
catch (loot::error &e) {
catch (loot::Error &e) {
return c_error(e);
}
catch (std::bad_alloc& e) {
@@ -360,7 +360,7 @@ LOOT_API unsigned int loot_apply_load_order(loot_db * const db,
try {
db->SetLoadOrder(loadOrder, numPlugins);
}
catch (loot::error &e) {
catch (loot::Error &e) {
return c_error(e);
}
@@ -383,7 +383,7 @@ LOOT_API unsigned int loot_update_masterlist(loot_db * const db,
loot::Masterlist masterlist;
*updated = masterlist.Update(masterlistPath, remoteURL, remoteBranch);
}
catch (loot::error &e) {
catch (loot::Error &e) {
return c_error(e);
}
@@ -418,7 +418,7 @@ LOOT_API unsigned int loot_get_masterlist_revision(loot_db * const db,
db->setRevisionIdString(id);
db->setRevisionDateString(date);
}
catch (loot::error &e) {
catch (loot::Error &e) {
if (e.code() == loot_ok)
return loot_ok;
else
@@ -532,7 +532,7 @@ LOOT_API unsigned int loot_get_plugin_tags(loot_db * const db, const char * cons
db->setAddedTags(tagsAdded);
db->setRemovedTags(tagsRemoved);
}
catch (loot::error& e) {
catch (loot::Error& e) {
return c_error(e);
}
+1 -1
View File
@@ -53,7 +53,7 @@ unsigned int loot_db::getBashTagUid(const std::string& name) const {
if (it != end(bashTagMap))
return it->second;
throw loot::error(loot::error::no_tag_map, "The Bash Tag \"" + name + "\" does not exist in the Bash Tag map.");
throw loot::Error(loot::Error::no_tag_map, "The Bash Tag \"" + name + "\" does not exist in the Bash Tag map.");
}
const std::vector<unsigned int>& loot_db::getAddedTagIds() const {
+1 -1
View File
@@ -89,7 +89,7 @@ namespace loot {
PWSTR path;
if (SHGetKnownFolderPath(FOLDERID_LocalAppData, 0, NULL, &path) != S_OK)
throw error(error::windows_error, boost::locale::translate("Failed to get %LOCALAPPDATA% path."));
throw Error(Error::windows_error, boost::locale::translate("Failed to get %LOCALAPPDATA% path."));
boost::filesystem::path localAppDataPath(FromWinWide(path));
CoTaskMemFree(path);
+3 -3
View File
@@ -186,8 +186,8 @@ namespace loot {
// Update game path in settings object.
storeGameSettings(ToGameSettings(_games));
}
catch (loot::error &e) {
if (e.code() == loot::error::no_game_detected) {
catch (loot::Error &e) {
if (e.code() == loot::Error::no_game_detected) {
_initErrors.push_back(e.what());
}
else {
@@ -270,7 +270,7 @@ namespace loot {
// 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 error(error::no_game_detected, translate("None of the supported games were detected."));
throw Error(Error::no_game_detected, translate("None of the supported games were detected."));
}
}
+3 -3
View File
@@ -29,10 +29,10 @@
#include <string>
namespace loot {
class error : public std::exception {
class Error : public std::exception {
public:
error(const unsigned int code_arg, const std::string& what_arg) : _code(code_arg), _what(what_arg) {}
~error() throw() {};
Error(const unsigned int code_arg, const std::string& what_arg) : _code(code_arg), _what(what_arg) {}
~Error() throw() {};
unsigned int code() const { return _code; }
const char * what() const throw() { return _what.c_str(); }
+3 -3
View File
@@ -55,14 +55,14 @@ namespace loot {
void Game::Init(bool createFolder, const boost::filesystem::path& gameLocalAppData) {
if (Id() != Game::tes4 && Id() != Game::tes5 && Id() != Game::fo3 && Id() != Game::fonv && Id() != Game::fo4) {
throw error(error::invalid_args, lc::translate("Invalid game ID supplied.").str());
throw Error(Error::invalid_args, lc::translate("Invalid game ID supplied.").str());
}
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 error(error::path_not_found, lc::translate("Game path could not be detected.").str());
throw Error(Error::path_not_found, lc::translate("Game path could not be detected.").str());
}
if (createFolder) {
@@ -73,7 +73,7 @@ namespace loot {
}
catch (fs::filesystem_error& e) {
BOOST_LOG_TRIVIAL(error) << "Could not create LOOT folder for game. Details: " << e.what();
throw error(error::path_write_fail, lc::translate("Could not create LOOT folder for game. Details:").str() + " " + e.what());
throw Error(Error::path_write_fail, lc::translate("Could not create LOOT folder for game. Details:").str() + " " + e.what());
}
}
+1 -1
View File
@@ -101,7 +101,7 @@ namespace loot {
if (it != end(plugins))
return it->second;
throw error(error::invalid_args, "No plugin \"" + pluginName + "\" exists.");
throw Error(Error::invalid_args, "No plugin \"" + pluginName + "\" exists.");
}
void GameCache::AddPlugin(const Plugin&& plugin) {
+7 -7
View File
@@ -47,12 +47,12 @@ namespace loot {
&& game.Id() != GameSettings::fo3
&& game.Id() != GameSettings::fonv
&& game.Id() != GameSettings::fo4) {
throw error(error::invalid_args, lc::translate("Unsupported game ID supplied.").str());
throw Error(Error::invalid_args, lc::translate("Unsupported game ID supplied.").str());
}
if (game.GamePath().empty()) {
BOOST_LOG_TRIVIAL(error) << "Game path is not initialised.";
throw error(error::invalid_args, lc::translate("Game path is not initialised.").str());
throw Error(Error::invalid_args, lc::translate("Game path is not initialised.").str());
}
const char * gameLocalDataPath = nullptr;
@@ -93,7 +93,7 @@ namespace loot {
err = lc::translate("libloadorder failed to create a game handle. Details:").str() + " " + e;
}
lo_cleanup();
throw error(error::liblo_error, err);
throw Error(Error::liblo_error, err);
}
}
@@ -115,7 +115,7 @@ namespace loot {
err = lc::translate("libloadorder failed to check if a plugin is active. Details:").str() + " " + e;
}
lo_cleanup();
throw error(error::liblo_error, err);
throw Error(Error::liblo_error, err);
}
return result;
@@ -141,7 +141,7 @@ namespace loot {
err = lc::translate("libloadorder failed to get the load order. Details:").str() + " " + e;
}
lo_cleanup();
throw error(error::liblo_error, err);
throw Error(Error::liblo_error, err);
}
std::list<std::string> loadOrder;
@@ -168,7 +168,7 @@ namespace loot {
err = lc::translate("libloadorder failed to set the load order. Details:").str() + " " + e;
}
lo_cleanup();
throw error(error::liblo_error, err);
throw Error(Error::liblo_error, err);
}
}
@@ -187,7 +187,7 @@ namespace loot {
try {
SetLoadOrder(pluginArr, pluginArrSize);
}
catch (error &/*e*/) {
catch (Error &/*e*/) {
for (size_t i = 0; i < pluginArrSize; i++)
delete[] pluginArr[i];
delete[] pluginArr;
+14 -14
View File
@@ -88,7 +88,7 @@ namespace loot {
errorMessage = (boost::format(lc::translate("Git operation failed. Error: %1%")) % gitError).str();
BOOST_LOG_TRIVIAL(error) << "Git operation failed. Error: " << gitError;
throw loot::error(loot::error::git_error, errorMessage);
throw loot::Error(loot::Error::git_error, errorMessage);
}
void GitHelper::SetErrorMessage(const std::string& message) {
@@ -158,7 +158,7 @@ namespace loot {
// Clones a repository and opens it.
void GitHelper::Clone(const boost::filesystem::path& path, const std::string& url) {
if (this->repo != nullptr)
throw error(error::git_error, "Cannot clone repository that has already been opened.");
throw Error(Error::git_error, "Cannot clone repository that has already been opened.");
this->SetErrorMessage(lc::translate("An error occurred while trying to clone the remote masterlist repository."));
// Clone the remote repository.
@@ -209,7 +209,7 @@ namespace loot {
void GitHelper::Fetch(const std::string& remote) {
if (this->repo == nullptr)
throw error(error::git_error, "Cannot fetch updates for repository that has not been opened.");
throw Error(Error::git_error, "Cannot fetch updates for repository that has not been opened.");
BOOST_LOG_TRIVIAL(trace) << "Fetching updates from remote.";
this->SetErrorMessage(lc::translate("An error occurred while trying to update the masterlist. This could be due to a server-side error. Try again in a few minutes."));
@@ -231,13 +231,13 @@ namespace loot {
void GitHelper::CheckoutNewBranch(const std::string& remote, const std::string& branch) {
if (this->repo == nullptr)
throw error(error::git_error, "Cannot fetch updates for repository that has not been opened.");
throw Error(Error::git_error, "Cannot fetch updates for repository that has not been opened.");
else if (this->commit != nullptr)
throw error(error::git_error, "Cannot fetch repository updates, commit memory already allocated.");
throw Error(Error::git_error, "Cannot fetch repository updates, commit memory already allocated.");
else if (this->obj != nullptr)
throw error(error::git_error, "Cannot fetch repository updates, object memory already allocated.");
throw Error(Error::git_error, "Cannot fetch repository updates, object memory already allocated.");
else if (this->ref != nullptr)
throw error(error::git_error, "Cannot fetch repository updates, reference memory already allocated.");
throw Error(Error::git_error, "Cannot fetch repository updates, reference memory already allocated.");
BOOST_LOG_TRIVIAL(trace) << "Looking up commit referred to by the remote branch \"" << branch << "\".";
this->Call(git_revparse_single(&this->obj, this->repo, (remote + "/" + branch).c_str()));
@@ -272,9 +272,9 @@ namespace loot {
void GitHelper::CheckoutRevision(const std::string& revision) {
if (this->repo == nullptr)
throw error(error::git_error, "Cannot checkout revision for repository that has not been opened.");
throw Error(Error::git_error, "Cannot checkout revision for repository that has not been opened.");
else if (this->obj != nullptr)
throw error(error::git_error, "Cannot fetch repository updates, object memory already allocated.");
throw Error(Error::git_error, "Cannot fetch repository updates, object memory already allocated.");
// Get an object ID for 'HEAD^'.
this->Call(git_revparse_single(&this->obj, this->repo, revision.c_str()));
@@ -293,13 +293,13 @@ namespace loot {
std::string GitHelper::GetHeadShortId() {
if (this->repo == nullptr)
throw error(error::git_error, "Cannot checkout revision for repository that has not been opened.");
throw Error(Error::git_error, "Cannot checkout revision for repository that has not been opened.");
else if (this->obj != nullptr)
throw error(error::git_error, "Cannot fetch repository updates, object memory already allocated.");
throw Error(Error::git_error, "Cannot fetch repository updates, object memory already allocated.");
else if (this->ref != nullptr)
throw error(error::git_error, "Cannot fetch repository updates, reference memory already allocated.");
throw Error(Error::git_error, "Cannot fetch repository updates, reference memory already allocated.");
else if (this->buf.ptr != nullptr)
throw error(error::git_error, "Cannot fetch repository updates, buffer memory already allocated.");
throw Error(Error::git_error, "Cannot fetch repository updates, buffer memory already allocated.");
BOOST_LOG_TRIVIAL(trace) << "Getting the Git object for HEAD.";
this->Call(git_repository_head(&this->ref, this->repo));
@@ -322,7 +322,7 @@ namespace loot {
bool GitHelper::IsFileDifferent(const boost::filesystem::path& repoRoot, const std::string& filename) {
if (!IsRepository(repoRoot)) {
BOOST_LOG_TRIVIAL(info) << "Unknown masterlist revision: Git repository missing.";
throw error(error::ok, lc::translate("Unknown: Git repository missing"));
throw Error(Error::ok, lc::translate("Unknown: Git repository missing"));
}
BOOST_LOG_TRIVIAL(debug) << "Existing repository found, attempting to open it.";
+4 -4
View File
@@ -86,7 +86,7 @@ namespace loot {
}
catch (exception&) {
BOOST_LOG_TRIVIAL(error) << "Unable to open \"" << filename.string() << "\" for CRC calculation.";
throw error(error::path_read_fail, (boost::format(lc::translate("Unable to open \"%1%\" for CRC calculation.")) % filename.string()).str());
throw Error(Error::path_read_fail, (boost::format(lc::translate("Unable to open \"%1%\" for CRC calculation.")) % filename.string()).str());
}
BOOST_LOG_TRIVIAL(debug) << "CRC32(\"" << filename.string() << "\"): " << std::hex << chksum << std::dec;
return chksum;
@@ -124,10 +124,10 @@ namespace loot {
#ifdef _WIN32
HINSTANCE ret = ShellExecute(0, NULL, ToWinWide(file.string()).c_str(), NULL, NULL, SW_SHOWNORMAL);
if ((int)ret <= 32)
throw error(error::windows_error, lc::translate("Failed to open file in its default application."));
throw Error(Error::windows_error, lc::translate("Failed to open file in its default application."));
#else
if (system(("/usr/bin/xdg-open" + file.string()).c_str()) != 0)
throw error(error::windows_error, lc::translate("Failed to open file in its default application."));
throw Error(Error::windows_error, lc::translate("Failed to open file in its default application."));
#endif
}
@@ -149,7 +149,7 @@ namespace loot {
else if (keyStr == "HKEY_USERS")
hKey = HKEY_USERS;
else
throw error(error::invalid_args, "Invalid registry key given.");
throw Error(Error::invalid_args, "Invalid registry key given.");
BOOST_LOG_TRIVIAL(trace) << "Getting string for registry key, subkey and value: " << keyStr << " + " << subkey << " + " << value;
LONG ret = RegGetValue(hKey,
+4 -4
View File
@@ -43,11 +43,11 @@ namespace loot {
if (!fs::exists(path)) {
BOOST_LOG_TRIVIAL(info) << "Unknown masterlist revision: No masterlist present.";
throw error(error::ok, lc::translate("N/A: No masterlist present"));
throw Error(Error::ok, lc::translate("N/A: No masterlist present"));
}
else if (!git.IsRepository(path.parent_path())) {
BOOST_LOG_TRIVIAL(info) << "Unknown masterlist revision: Git repository missing.";
throw error(error::ok, lc::translate("Unknown: Git repository missing"));
throw Error(Error::ok, lc::translate("Unknown: Git repository missing"));
}
BOOST_LOG_TRIVIAL(debug) << "Existing repository found, attempting to open it.";
@@ -95,7 +95,7 @@ namespace loot {
string filename = path.filename().string();
if (repoUrl.empty() || repoBranch.empty())
throw error(error::invalid_args, "Repository URL and branch must not be empty.");
throw Error(Error::invalid_args, "Repository URL and branch must not be empty.");
// Initialise checkout options.
BOOST_LOG_TRIVIAL(debug) << "Setting up checkout options.";
@@ -268,7 +268,7 @@ namespace loot {
} while (parsingFailed);
if (!parsingError.empty())
throw error(error::ok, parsingError); //Throw an OK because the process still completed in a successful state.
throw Error(Error::ok, parsingError); //Throw an OK because the process still completed in a successful state.
return true;
}
+7 -7
View File
@@ -152,7 +152,7 @@ namespace loot {
if (!IsSafePath(file)) {
BOOST_LOG_TRIVIAL(error) << "Invalid file path: " << file;
throw loot::error(loot::error::invalid_args, boost::locale::translate("Invalid file path:").str() + " " + file);
throw loot::Error(loot::Error::invalid_args, boost::locale::translate("Invalid file path:").str() + " " + file);
}
if (_game == nullptr)
@@ -195,7 +195,7 @@ namespace loot {
std::regex(regex, std::regex::ECMAScript | std::regex::icase);
}
catch (std::regex_error& e) {
throw loot::error(loot::error::invalid_args, (boost::format(boost::locale::translate("Invalid regex string \"%1%\": %2%")) % regex % e.what()).str());
throw loot::Error(loot::Error::invalid_args, (boost::format(boost::locale::translate("Invalid regex string \"%1%\": %2%")) % regex % e.what()).str());
}
std::regex sepReg("/|(\\\\\\\\)", std::regex::ECMAScript);
@@ -213,7 +213,7 @@ namespace loot {
if (!IsSafePath(parent)) {
BOOST_LOG_TRIVIAL(error) << "Invalid folder path: " << parent;
throw loot::error(loot::error::invalid_args, boost::locale::translate("Invalid folder path:").str() + " " + parent.string());
throw loot::Error(loot::Error::invalid_args, boost::locale::translate("Invalid folder path:").str() + " " + parent.string());
}
std::regex reg;
@@ -222,7 +222,7 @@ namespace loot {
}
catch (std::regex_error& e) {
BOOST_LOG_TRIVIAL(error) << "Invalid regex string:" << filename;
throw loot::error(loot::error::invalid_args, (boost::format(boost::locale::translate("Invalid regex string \"%1%\": %2%")) % filename % e.what()).str());
throw loot::Error(loot::Error::invalid_args, (boost::format(boost::locale::translate("Invalid regex string \"%1%\": %2%")) % filename % e.what()).str());
}
return std::pair<boost::filesystem::path, std::regex>(parent, reg);
@@ -290,7 +290,7 @@ namespace loot {
if (!IsSafePath(file)) {
BOOST_LOG_TRIVIAL(error) << "Invalid file path: " << file;
throw loot::error(loot::error::invalid_args, boost::locale::translate("Invalid file path:").str() + " " + file);
throw loot::Error(loot::Error::invalid_args, boost::locale::translate("Invalid file path:").str() + " " + file);
}
if (_game == nullptr)
@@ -378,7 +378,7 @@ namespace loot {
void CheckActive(bool& result, const std::string& file) const {
if (!IsSafePath(file)) {
BOOST_LOG_TRIVIAL(error) << "Invalid file path: " << file;
throw loot::error(loot::error::invalid_args, boost::locale::translate("Invalid file path:").str() + " " + file);
throw loot::Error(loot::Error::invalid_args, boost::locale::translate("Invalid file path:").str() + " " + file);
}
if (_game == nullptr)
@@ -398,7 +398,7 @@ namespace loot {
BOOST_LOG_TRIVIAL(error) << "Expected \"" << what.tag << "\" at \"" << context << "\".";
throw loot::error(loot::error::condition_eval_fail, (boost::format(boost::locale::translate("Expected \"%1%\" at \"%2%\".")) % what.tag % context).str());
throw loot::Error(loot::Error::condition_eval_fail, (boost::format(boost::locale::translate("Expected \"%1%\" at \"%2%\".")) % what.tag % context).str());
}
//Checks that the path (not regex) doesn't go outside any game folders.
@@ -69,12 +69,12 @@ namespace loot {
}
catch (std::exception& e) {
BOOST_LOG_TRIVIAL(error) << "Failed to parse condition \"" << _condition << "\": " << e.what();
throw loot::error(loot::error::condition_eval_fail, (boost::format(lc::translate("Failed to parse condition \"%1%\": %2%")) % _condition % e.what()).str());
throw loot::Error(loot::Error::condition_eval_fail, (boost::format(lc::translate("Failed to parse condition \"%1%\": %2%")) % _condition % e.what()).str());
}
if (!r || begin != end) {
BOOST_LOG_TRIVIAL(error) << "Failed to parse condition \"" << _condition << "\".";
throw loot::error(loot::error::condition_eval_fail, (boost::format(lc::translate("Failed to parse condition \"%1%\".")) % _condition).str());
throw loot::Error(loot::Error::condition_eval_fail, (boost::format(lc::translate("Failed to parse condition \"%1%\".")) % _condition).str());
}
game.CacheCondition(_condition, eval);
@@ -101,12 +101,12 @@ namespace loot {
}
catch (std::exception& e) {
BOOST_LOG_TRIVIAL(error) << "Failed to parse condition \"" << _condition << "\": " << e.what();
throw loot::error(loot::error::condition_eval_fail, (boost::format(lc::translate("Failed to parse condition \"%1%\": %2%")) % _condition % e.what()).str());
throw loot::Error(loot::Error::condition_eval_fail, (boost::format(lc::translate("Failed to parse condition \"%1%\": %2%")) % _condition % e.what()).str());
}
if (!r || begin != end) {
BOOST_LOG_TRIVIAL(error) << "Failed to parse condition \"" << _condition << "\".";
throw loot::error(loot::error::condition_eval_fail, (boost::format(lc::translate("Failed to parse condition \"%1%\".")) % _condition).str());
throw loot::Error(loot::Error::condition_eval_fail, (boost::format(lc::translate("Failed to parse condition \"%1%\".")) % _condition).str());
}
}
}
+1 -1
View File
@@ -51,7 +51,7 @@ namespace loot {
englishStringExists = true;
}
if (!englishStringExists)
throw loot::error(error::invalid_args, "bad conversion: multilingual messages must contain an English content string");
throw loot::Error(Error::invalid_args, "bad conversion: multilingual messages must contain an English content string");
}
}
+1 -1
View File
@@ -277,7 +277,7 @@ namespace loot {
void PluginMetadata::Priority(const int p) {
if (abs(p) >= yamlGlobalPriorityDivisor)
throw error(error::invalid_args, "Cannot set priority that has an absolute value greater than or equal to " + to_string(yamlGlobalPriorityDivisor));
throw Error(Error::invalid_args, "Cannot set priority that has an absolute value greater than or equal to " + to_string(yamlGlobalPriorityDivisor));
priority = p;
}
+3 -3
View File
@@ -39,7 +39,7 @@ namespace loot {
boost::filesystem::ifstream in(filepath);
if (!in.good())
throw error(error::path_read_fail, "Cannot open " + filepath.string());
throw Error(Error::path_read_fail, "Cannot open " + filepath.string());
YAML::Node metadataList = YAML::Load(in);
in.close();
@@ -51,7 +51,7 @@ namespace loot {
regexPlugins.push_back(plugin);
else {
if (!plugins.insert(plugin).second)
throw error(error::path_read_fail, "More than one entry exists for \"" + plugin.Name() + "\"");
throw Error(Error::path_read_fail, "More than one entry exists for \"" + plugin.Name() + "\"");
}
}
}
@@ -127,7 +127,7 @@ namespace loot {
regexPlugins.push_back(plugin);
else {
if (!plugins.insert(plugin).second)
throw error(error::invalid_args, "Cannot add \"" + plugin.Name() + "\" to the metadata list as another entry already exists.");
throw Error(Error::invalid_args, "Cannot add \"" + plugin.Name() + "\" to the metadata list as another entry already exists.");
}
}
+4 -4
View File
@@ -76,7 +76,7 @@ namespace loot {
BOOST_LOG_TRIVIAL(error) << "Cyclic interaction detected between plugins \"" << graph[source].Name() << "\" and \"" << graph[target].Name() << "\". Back cycle: " << backCycle;
throw loot::error(loot::error::sorting_error, (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 loot::Error(loot::Error::sorting_error, (boost::format(boost::locale::translate("Cyclic interaction detected between plugins \"%1%\" and \"%2%\". Back cycle: %3%")) % graph[source].Name() % graph[target].Name() % backCycle).str());
}
private:
@@ -89,7 +89,7 @@ namespace loot {
inline void discover_vertex(vertex_t vertex, const PluginGraph& graph) {
if (vertex == target)
throw error(error::ok, "Found a path.");
throw Error(Error::ok, "Found a path.");
}
private:
@@ -246,8 +246,8 @@ namespace loot {
try {
boost::breadth_first_search(graph, toVertex, visitor(PathDetector(fromVertex)).vertex_index_map(vertexIndexMap));
}
catch (error& e) {
if (e.code() == error::ok)
catch (Error& e) {
if (e.code() == Error::ok)
return true;
}
return false;
+21 -21
View File
@@ -71,7 +71,7 @@ namespace loot {
OpenReadme();
callback->Success("");
}
catch (error &e) {
catch (Error &e) {
BOOST_LOG_TRIVIAL(error) << e.what();
callback->Failure(e.code(), e.what());
}
@@ -86,7 +86,7 @@ namespace loot {
OpenLogLocation();
callback->Success("");
}
catch (error &e) {
catch (Error &e) {
BOOST_LOG_TRIVIAL(error) << e.what();
callback->Failure(e.code(), e.what());
}
@@ -135,7 +135,7 @@ namespace loot {
_lootState.CurrentGame().RedatePlugins();
callback->Success("");
}
catch (error &e) {
catch (Error &e) {
BOOST_LOG_TRIVIAL(error) << "Failed to redate plugins. " << e.what();
callback->Failure(e.code(), e.what());
}
@@ -222,7 +222,7 @@ namespace loot {
CefPostTask(TID_FILE, base::Bind(&QueryHandler::GetGameData, base::Unretained(this), frame, callback));
}
catch (loot::error &e) {
catch (loot::Error &e) {
BOOST_LOG_TRIVIAL(error) << "Failed to change game. Details: " << e.what();
callback->Failure(e.code(), (boost::format(loc::translate("Failed to change game. Details: %1%")) % e.what()).str());
}
@@ -243,7 +243,7 @@ namespace loot {
CopyMetadata(request["args"][0].as<string>());
callback->Success("");
}
catch (loot::error &e) {
catch (loot::Error &e) {
BOOST_LOG_TRIVIAL(error) << "Failed to copy plugin metadata. Details: " << e.what();
callback->Failure(e.code(), (boost::format(loc::translate("Failed to copy plugin metadata. Details: %1%")) % e.what()).str());
}
@@ -265,7 +265,7 @@ namespace loot {
callback->Success(ApplyUserEdits(request["args"][0]));
_lootState.decrementUnappliedChangeCounter();
}
catch (loot::error &e) {
catch (loot::Error &e) {
BOOST_LOG_TRIVIAL(error) << "Failed to apply plugin metadata. Details: " << e.what();
callback->Failure(e.code(), (boost::format(loc::translate("Failed to apply plugin metadata. Details: %1%")) % e.what()).str());
}
@@ -309,7 +309,7 @@ namespace loot {
_lootState.CurrentGame().SetLoadOrder(request["args"][0].as<list<string>>());
callback->Success("");
}
catch (error &e) {
catch (Error &e) {
BOOST_LOG_TRIVIAL(error) << e.what();
callback->Failure(e.code(), e.what());
}
@@ -333,7 +333,7 @@ namespace loot {
CopyToClipboard(text);
callback->Success("");
}
catch (loot::error &e) {
catch (loot::Error &e) {
BOOST_LOG_TRIVIAL(error) << "Failed to copy plugin metadata. Details: " << e.what();
callback->Failure(e.code(), (boost::format(loc::translate("Failed to copy plugin metadata. Details: %1%")) % e.what()).str());
}
@@ -369,7 +369,7 @@ namespace loot {
CopyToClipboard(ss.str());
callback->Success("");
}
catch (loot::error &e) {
catch (loot::Error &e) {
BOOST_LOG_TRIVIAL(error) << "Failed to copy plugin metadata. Details: " << e.what();
callback->Failure(e.code(), (boost::format(loc::translate("Failed to copy plugin metadata. Details: %1%")) % e.what()).str());
}
@@ -693,7 +693,7 @@ namespace loot {
gameNode["masterlist"]["revision"] = info.revision;
gameNode["masterlist"]["date"] = info.date;
}
catch (error &e) {
catch (Error &e) {
gameNode["masterlist"]["revision"] = e.what();
gameNode["masterlist"]["date"] = e.what();
}
@@ -770,7 +770,7 @@ namespace loot {
callback->Success(JSON::stringify(gameNode));
}
catch (loot::error &e) {
catch (loot::Error &e) {
BOOST_LOG_TRIVIAL(error) << "Failed to get game data. Details: " << e.what();
callback->Failure(e.code(), (boost::format(loc::translate("Failed to get game data. Details: %1%")) % e.what()).str());
}
@@ -788,8 +788,8 @@ namespace loot {
try {
wasChanged = _lootState.CurrentGame().GetMasterlist().Update(_lootState.CurrentGame());
}
catch (loot::error &e) {
if (e.code() == loot::error::ok) {
catch (loot::Error &e) {
if (e.code() == loot::Error::ok) {
// There was a parsing error, but roll-back was successful, so the process
// should still complete.
@@ -817,7 +817,7 @@ namespace loot {
gameNode["masterlist"]["revision"] = info.revision;
gameNode["masterlist"]["date"] = info.date;
}
catch (error &e) {
catch (Error &e) {
gameNode["masterlist"]["revision"] = e.what();
gameNode["masterlist"]["date"] = e.what();
}
@@ -861,7 +861,7 @@ namespace loot {
else
callback->Success("null");
}
catch (error &e) {
catch (Error &e) {
BOOST_LOG_TRIVIAL(error) << "Failed to update the masterlist. Details: " << e.what();
callback->Failure(e.code(), (boost::format(loc::translate("Failed to update the masterlist. Details: %1%")) % e.what()).str());
}
@@ -959,9 +959,9 @@ namespace loot {
else
callback->Success("null");
}
catch (loot::error& e) {
catch (loot::Error& e) {
BOOST_LOG_TRIVIAL(error) << "Failed to sort plugins. Details: " << e.what();
if (e.code() == error::sorting_error) {
if (e.code() == Error::sorting_error) {
_lootState.CurrentGame().AppendMessage(Message(Message::error, e.what()));
YAML::Node node;
@@ -1059,11 +1059,11 @@ namespace loot {
void QueryHandler::CopyToClipboard(const std::string& text) {
#ifdef _WIN32
if (!OpenClipboard(NULL)) {
throw loot::error(loot::error::windows_error, "Failed to open the Windows clipboard.");
throw loot::Error(loot::Error::windows_error, "Failed to open the Windows clipboard.");
}
if (!EmptyClipboard()) {
throw loot::error(loot::error::windows_error, "Failed to empty the Windows clipboard.");
throw loot::Error(loot::Error::windows_error, "Failed to empty the Windows clipboard.");
}
// The clipboard takes a Unicode (ie. UTF-16) string that it then owns and must not
@@ -1074,11 +1074,11 @@ namespace loot {
wcscpy(wcstr, wtext.c_str());
if (SetClipboardData(CF_UNICODETEXT, wcstr) == NULL) {
throw loot::error(loot::error::windows_error, "Failed to copy metadata to the Windows clipboard.");
throw loot::Error(loot::Error::windows_error, "Failed to copy metadata to the Windows clipboard.");
}
if (!CloseClipboard()) {
throw loot::error(loot::error::windows_error, "Failed to close the Windows clipboard.");
throw loot::Error(loot::Error::windows_error, "Failed to close the Windows clipboard.");
}
#endif
}
+10 -10
View File
@@ -94,10 +94,10 @@ namespace loot {
TEST_P(GameTest, initShouldThrowIfGameHasAnInvalidId) {
Game game;
EXPECT_THROW(game.Init(false), error);
EXPECT_THROW(game.Init(true), error);
EXPECT_THROW(game.Init(false, localPath), error);
EXPECT_THROW(game.Init(true, localPath), error);
EXPECT_THROW(game.Init(false), Error);
EXPECT_THROW(game.Init(true), Error);
EXPECT_THROW(game.Init(false, localPath), Error);
EXPECT_THROW(game.Init(true, localPath), Error);
}
TEST_P(GameTest, getArchiveFileExtensionShouldReturnDotBa2ForFallout4AndDotBsaForOtherGames) {
@@ -113,16 +113,16 @@ namespace loot {
// test autodetection fully unless on Linux.
TEST_P(GameTest, initShouldThrowOnLinuxIfGamePathIsNotGiven) {
Game game = Game(GetParam());
EXPECT_THROW(game.Init(false), error);
EXPECT_THROW(game.Init(true), error);
EXPECT_THROW(game.Init(false, localPath), error);
EXPECT_THROW(game.Init(true, localPath), error);
EXPECT_THROW(game.Init(false), Error);
EXPECT_THROW(game.Init(true), Error);
EXPECT_THROW(game.Init(false, localPath), Error);
EXPECT_THROW(game.Init(true, localPath), Error);
}
TEST_P(GameTest, initShouldThrowOnLinuxIfLocalPathIsNotGiven) {
Game game = Game(GetParam()).SetGamePath(dataPath.parent_path());
ASSERT_FALSE(boost::filesystem::exists(LootPaths::getLootDataPath() / game.FolderName()));
EXPECT_THROW(game.Init(false), error);
EXPECT_THROW(game.Init(false), Error);
}
// Testing on Windows will find real LOOT installs, and they shouldn't be
@@ -163,7 +163,7 @@ namespace loot {
game.SetGamePath(dataPath.parent_path());
if (GetParam() == Game::tes5)
EXPECT_THROW(game.RedatePlugins(), error);
EXPECT_THROW(game.RedatePlugins(), Error);
else
EXPECT_NO_THROW(game.RedatePlugins());
}
@@ -52,19 +52,19 @@ namespace loot {
GameSettings game(GameSettings::autodetect);
game.SetGamePath(dataPath.parent_path());
EXPECT_THROW(loh.Init(game), error);
EXPECT_THROW(loh.Init(game), error);
EXPECT_THROW(loh.Init(game, localPath), error);
EXPECT_THROW(loh.Init(game, localPath), error);
EXPECT_THROW(loh.Init(game), Error);
EXPECT_THROW(loh.Init(game), Error);
EXPECT_THROW(loh.Init(game, localPath), Error);
EXPECT_THROW(loh.Init(game, localPath), Error);
}
TEST_P(LoadOrderHandlerTest, initShouldThrowIfNoGamePathIsSet) {
GameSettings game(GetParam());
EXPECT_THROW(loh.Init(game), error);
EXPECT_THROW(loh.Init(game), error);
EXPECT_THROW(loh.Init(game, localPath), error);
EXPECT_THROW(loh.Init(game, localPath), error);
EXPECT_THROW(loh.Init(game), Error);
EXPECT_THROW(loh.Init(game), Error);
EXPECT_THROW(loh.Init(game, localPath), Error);
EXPECT_THROW(loh.Init(game, localPath), Error);
}
#ifndef _WIN32
@@ -72,7 +72,7 @@ namespace loot {
GameSettings game(GetParam());
game.SetGamePath(dataPath.parent_path());
EXPECT_THROW(loh.Init(game), error);
EXPECT_THROW(loh.Init(game), Error);
}
#endif
@@ -84,7 +84,7 @@ namespace loot {
}
TEST_P(LoadOrderHandlerTest, isPluginActiveShouldThrowIfTheHandlerHasNotBeenInitialised) {
EXPECT_THROW(loh.IsPluginActive(masterFile), error);
EXPECT_THROW(loh.IsPluginActive(masterFile), Error);
}
TEST_P(LoadOrderHandlerTest, isPluginActiveShouldReturnCorrectPluginStatesAfterInitialisation) {
@@ -98,7 +98,7 @@ namespace loot {
}
TEST_P(LoadOrderHandlerTest, getLoadOrderShouldThrowIfTheHandlerHasNotBeenInitialised) {
EXPECT_THROW(loh.GetLoadOrder(), error);
EXPECT_THROW(loh.GetLoadOrder(), Error);
}
TEST_P(LoadOrderHandlerTest, getLoadOrderShouldReturnTheCurrentLoadOrder) {
@@ -124,7 +124,7 @@ namespace loot {
blankPluginDependentEsp,
});
EXPECT_THROW(loh.SetLoadOrder(std::list<std::string>()), error);
EXPECT_THROW(loh.SetLoadOrder(std::list<std::string>()), Error);
}
TEST_P(LoadOrderHandlerTest, setLoadOrderShouldSetTheLoadOrder) {

Some files were not shown because too many files have changed in this diff Show More