mirror of
https://github.com/loot/libloot.git
synced 2026-07-27 14:16:01 -07:00
Expose loot-condition-interpreter error codes to callers
Make ConditionSyntaxError extend from system_error instead of directly from runtime_error, so that callers can use the exception's code to distinguish between different causes.
This commit is contained in:
@@ -47,6 +47,16 @@ class libloadorder_category : public std::error_category {
|
||||
return code.category().name() == name();
|
||||
}
|
||||
};
|
||||
|
||||
class loot_condition_interpreter_category : public std::error_category {
|
||||
const char* name() const noexcept override { return "loot condition interpreter"; }
|
||||
|
||||
std::string message(int) const override { return "loot condition interpreter error"; }
|
||||
|
||||
bool equivalent(const std::error_code& code, int) const noexcept override {
|
||||
return code.category().name() == name();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
LOOT_API const std::error_category& esplugin_category() {
|
||||
@@ -58,4 +68,9 @@ LOOT_API const std::error_category& libloadorder_category() {
|
||||
static detail::libloadorder_category instance;
|
||||
return instance;
|
||||
}
|
||||
|
||||
LOOT_API const std::error_category& loot_condition_interpreter_category() {
|
||||
static detail::loot_condition_interpreter_category instance;
|
||||
return instance;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
#include "api/helpers/crc.h"
|
||||
#include "api/helpers/logging.h"
|
||||
#include "loot/exception/condition_syntax_error.h"
|
||||
#include "loot/exception/error_categories.h"
|
||||
|
||||
namespace loot {
|
||||
void HandleError(const std::string operation, int returnCode) {
|
||||
@@ -50,7 +51,7 @@ void HandleError(const std::string operation, int returnCode) {
|
||||
logger->error(err);
|
||||
}
|
||||
|
||||
throw ConditionSyntaxError(err);
|
||||
throw ConditionSyntaxError(returnCode, loot_condition_interpreter_category(), err);
|
||||
}
|
||||
|
||||
int mapGameType(GameType gameType) {
|
||||
|
||||
Reference in New Issue
Block a user