mirror of
https://github.com/loot/libloot.git
synced 2026-07-27 14:16:01 -07:00
Remove libloadorder_category()
Throw errors from libloadorder as std::runtime_error instead of std::system_error.
This commit is contained in:
@@ -37,25 +37,10 @@ class esplugin_category : public std::error_category {
|
||||
return code.category().name() == name();
|
||||
}
|
||||
};
|
||||
|
||||
class libloadorder_category : public std::error_category {
|
||||
const char* name() const noexcept override { return "libloadorder"; }
|
||||
|
||||
std::string message(int) const override { return "Libloadorder 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() {
|
||||
static detail::esplugin_category instance;
|
||||
return instance;
|
||||
}
|
||||
|
||||
LOOT_API const std::error_category& libloadorder_category() {
|
||||
static detail::libloadorder_category instance;
|
||||
return instance;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,6 @@ constexpr std::string_view CYCLIC_ERROR_PREFIX = "CyclicInteractionError: "sv;
|
||||
constexpr std::string_view UNDEFINED_GROUP_ERROR_PREFIX =
|
||||
"UndefinedGroupError: "sv;
|
||||
constexpr std::string_view ESPLUGIN_ERROR_PREFIX = "EspluginError: "sv;
|
||||
constexpr std::string_view LIBLOADORDER_ERROR_PREFIX = "LibloadorderError: "sv;
|
||||
constexpr std::string_view INVALID_ARGUMENT_PREFIX = "InvalidArgument: "sv;
|
||||
|
||||
bool startsWith(std::string_view str, std::string_view prefix) {
|
||||
@@ -143,14 +142,6 @@ std::exception_ptr mapError(const ::rust::Error& error) {
|
||||
|
||||
return std::make_exception_ptr(
|
||||
std::system_error(code, esplugin_category(), details));
|
||||
|
||||
} else if (startsWith(error.what(), LIBLOADORDER_ERROR_PREFIX)) {
|
||||
const auto [code, details] =
|
||||
parseSystemError(std::string_view(error.what())
|
||||
.substr(LIBLOADORDER_ERROR_PREFIX.size()));
|
||||
|
||||
return std::make_exception_ptr(
|
||||
std::system_error(code, libloadorder_category(), details));
|
||||
} else if (startsWith(error.what(), INVALID_ARGUMENT_PREFIX)) {
|
||||
return std::make_exception_ptr(
|
||||
std::invalid_argument(getErrorSuffix(error.what())));
|
||||
|
||||
Reference in New Issue
Block a user