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:
@@ -105,5 +105,3 @@ LOOT uses error category objects to identify errors with codes that originate in
|
||||
lower-level libraries.
|
||||
|
||||
.. doxygenfunction:: loot::esplugin_category
|
||||
|
||||
.. doxygenfunction:: loot::libloadorder_category
|
||||
|
||||
@@ -37,14 +37,6 @@ namespace loot {
|
||||
* derived from std::error_category.
|
||||
*/
|
||||
LOOT_API const std::error_category& esplugin_category();
|
||||
|
||||
/**
|
||||
* @brief Get the error category that can be used to identify system_error
|
||||
* exceptions that are due to libloadorder errors.
|
||||
* @returns A reference to the static object of unspecified runtime type,
|
||||
* derived from std::error_category.
|
||||
*/
|
||||
LOOT_API const std::error_category& libloadorder_category();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,7 +25,6 @@
|
||||
#include "api/game/load_order_handler.h"
|
||||
|
||||
#include "api/helpers/logging.h"
|
||||
#include "loot/exception/error_categories.h"
|
||||
|
||||
namespace loot {
|
||||
unsigned int mapGameId(GameType gameType) {
|
||||
@@ -298,14 +297,14 @@ void LoadOrderHandler::HandleError(std::string_view operation,
|
||||
return;
|
||||
}
|
||||
|
||||
const char* e = nullptr;
|
||||
const char* message = nullptr;
|
||||
std::string err;
|
||||
lo_get_error_message(&e);
|
||||
if (e == nullptr) {
|
||||
lo_get_error_message(&message);
|
||||
if (message == nullptr) {
|
||||
err = fmt::format(
|
||||
"libloadorder failed to {}. Details could not be fetched.", operation);
|
||||
"Failed to {}. libloadorder error code: {}", operation, returnCode);
|
||||
} else {
|
||||
err = fmt::format("libloadorder failed to {}. Details: {}", operation, e);
|
||||
err = fmt::format("Failed to {}. Details: {}", operation, message);
|
||||
}
|
||||
|
||||
auto logger = getLogger();
|
||||
@@ -313,6 +312,6 @@ void LoadOrderHandler::HandleError(std::string_view operation,
|
||||
logger->error(err);
|
||||
}
|
||||
|
||||
throw std::system_error(returnCode, libloadorder_category(), err);
|
||||
throw std::runtime_error(err);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -150,7 +150,7 @@ TEST_P(
|
||||
GetParam() == GameType::oblivionRemastered) {
|
||||
EXPECT_NO_THROW(CreateGameHandle(GetParam(), gamePath));
|
||||
} else {
|
||||
EXPECT_THROW(CreateGameHandle(GetParam(), gamePath), std::system_error);
|
||||
EXPECT_THROW(CreateGameHandle(GetParam(), gamePath), std::runtime_error);
|
||||
}
|
||||
}
|
||||
#else
|
||||
|
||||
@@ -26,7 +26,6 @@ along with LOOT. If not, see
|
||||
#define LOOT_TESTS_API_INTERNALS_GAME_GAME_TEST
|
||||
|
||||
#include "api/game/game.h"
|
||||
#include "loot/exception/error_categories.h"
|
||||
#include "tests/common_game_test_fixture.h"
|
||||
|
||||
namespace loot {
|
||||
|
||||
@@ -151,7 +151,7 @@ TEST_P(LoadOrderHandlerTest,
|
||||
GetParam() == GameType::oblivionRemastered) {
|
||||
EXPECT_NO_THROW(LoadOrderHandler(GetParam(), gamePath));
|
||||
} else {
|
||||
EXPECT_THROW(LoadOrderHandler(GetParam(), gamePath), std::system_error);
|
||||
EXPECT_THROW(LoadOrderHandler(GetParam(), gamePath), std::runtime_error);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user