Add UndefinedGroupError for better sorting exception handling

This commit is contained in:
Oliver Hamlet
2018-03-24 07:20:47 +00:00
parent ae081aff3b
commit eeb6ed40c7
8 changed files with 71 additions and 5 deletions
+1
View File
@@ -37,6 +37,7 @@
#include "loot/exception/error_categories.h"
#include "loot/exception/file_access_error.h"
#include "loot/exception/git_state_error.h"
#include "loot/exception/undefined_group_error.h"
#include "loot/game_interface.h"
#include "loot/loot_version.h"
@@ -0,0 +1,58 @@
/* LOOT
A load order optimisation tool for Oblivion, Skyrim, Fallout 3 and
Fallout: New Vegas.
Copyright (C) 2012-2016 WrinklyNinja
This file is part of LOOT.
LOOT is free software: you can redistribute
it and/or modify it under the terms of the GNU General Public License
as published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.
LOOT is distributed in the hope that it will
be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with LOOT. If not, see
<https://www.gnu.org/licenses/>.
*/
#ifndef LOOT_EXCEPTION_UNDEFINED_GROUP_ERROR
#define LOOT_EXCEPTION_UNDEFINED_GROUP_ERROR
#include <stdexcept>
namespace loot {
/**
* @brief An exception class thrown if group is referenced but is undefined.
*/
class UndefinedGroupError : public std::runtime_error {
public:
/**
* @brief Construct an exception detailing a plugin graph cycle.
* @param firstPlugin A plugin in the cycle.
* @param lastPlugin Another plugin in the cycle.
* @param backCycle A string describing the path from lastPlugin to
* firstPlugin.
*/
UndefinedGroupError(const std::string& groupName) :
std::runtime_error("The group \"" + groupName + "\" does not exist"),
groupName_(groupName) {}
/**
* Get the name of the undefined group.
* @return A group name.
*/
std::string getGroupName() { return groupName_; }
private:
const std::string groupName_;
};
}
#endif