Rework handling of esplugin errors

The error scenario represented by PluginNotLoadedError is distinguished from all other esplugin errors by LOOT, so it's worth handling separately.
This commit is contained in:
Oliver Hamlet
2025-06-08 20:26:07 +01:00
parent 05c984c769
commit 11bd321861
20 changed files with 81 additions and 321 deletions
+1 -1
View File
@@ -35,7 +35,7 @@
#include "loot/enum/game_type.h"
#include "loot/enum/log_level.h"
#include "loot/exception/cyclic_interaction_error.h"
#include "loot/exception/error_categories.h"
#include "loot/exception/plugin_not_loaded_error.h"
#include "loot/exception/undefined_group_error.h"
#include "loot/game_interface.h"
#include "loot/loot_version.h"
@@ -22,21 +22,20 @@
<https://www.gnu.org/licenses/>.
*/
#ifndef LOOT_ERROR_CATEGORIES
#define LOOT_ERROR_CATEGORIES
#ifndef LOOT_EXCEPTION_PLUGIN_NOT_LOADED_ERROR
#define LOOT_EXCEPTION_PLUGIN_NOT_LOADED_ERROR
#include <system_error>
#include "loot/api_decorator.h"
#include <stdexcept>
namespace loot {
/**
* @brief Get the error category that can be used to identify system_error
* exceptions that are due to esplugin errors.
* @returns A reference to the static object of unspecified runtime type,
* derived from std::error_category.
* @brief An exception class thrown if a plugin that must be loaded hasn't been
* loaded.
*/
LOOT_API const std::error_category& esplugin_category();
class PluginNotLoadedError : public std::runtime_error {
public:
using std::runtime_error::runtime_error;
};
}
#endif