diff --git a/CMakeLists.txt b/CMakeLists.txt index b3b52a6f..76797bf8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -232,7 +232,6 @@ set(LIBLOOT_INCLUDE_H_FILES "${CMAKE_SOURCE_DIR}/include/loot/api_decorator.h" "${CMAKE_SOURCE_DIR}/include/loot/database_interface.h" "${CMAKE_SOURCE_DIR}/include/loot/exception/error_categories.h" - "${CMAKE_SOURCE_DIR}/include/loot/exception/condition_syntax_error.h" "${CMAKE_SOURCE_DIR}/include/loot/exception/cyclic_interaction_error.h" "${CMAKE_SOURCE_DIR}/include/loot/exception/undefined_group_error.h" "${CMAKE_SOURCE_DIR}/include/loot/enum/edge_type.h" diff --git a/docs/api/reference.rst b/docs/api/reference.rst index 5f32dd42..e12f4f53 100644 --- a/docs/api/reference.rst +++ b/docs/api/reference.rst @@ -95,9 +95,6 @@ Exceptions .. doxygenclass:: loot::CyclicInteractionError :members: -.. doxygenclass:: loot::ConditionSyntaxError - :members: - .. doxygenclass:: loot::UndefinedGroupError :members: diff --git a/include/loot/api.h b/include/loot/api.h index bdf79f33..abdd10eb 100644 --- a/include/loot/api.h +++ b/include/loot/api.h @@ -34,7 +34,6 @@ #include "loot/api_decorator.h" #include "loot/enum/game_type.h" #include "loot/enum/log_level.h" -#include "loot/exception/condition_syntax_error.h" #include "loot/exception/cyclic_interaction_error.h" #include "loot/exception/error_categories.h" #include "loot/exception/undefined_group_error.h" diff --git a/include/loot/exception/condition_syntax_error.h b/include/loot/exception/condition_syntax_error.h deleted file mode 100644 index c3f0b18d..00000000 --- a/include/loot/exception/condition_syntax_error.h +++ /dev/null @@ -1,41 +0,0 @@ -/* 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 - . - */ - -#ifndef LOOT_EXCEPTION_CONDITION_SYNTAX_ERROR -#define LOOT_EXCEPTION_CONDITION_SYNTAX_ERROR - -#include - -namespace loot { -/** - * @brief An exception class thrown if invalid syntax is encountered when - * parsing a metadata condition. - */ -class ConditionSyntaxError : public std::system_error { -public: - using std::system_error::system_error; -}; -} - -#endif diff --git a/include/loot/exception/error_categories.h b/include/loot/exception/error_categories.h index 710cfa5a..42773fcc 100644 --- a/include/loot/exception/error_categories.h +++ b/include/loot/exception/error_categories.h @@ -45,14 +45,6 @@ LOOT_API const std::error_category& esplugin_category(); * derived from std::error_category. */ LOOT_API const std::error_category& libloadorder_category(); - -/** - * @brief Get the error category that can be used to identify system_error - * exceptions that are due to loot condition interpreter errors. - * @returns A reference to the static object of unspecified runtime type, - * derived from std::error_category. - */ -LOOT_API const std::error_category& loot_condition_interpreter_category(); } #endif diff --git a/src/api/exception/error_categories.cpp b/src/api/exception/error_categories.cpp index 783d08c2..b4bd9521 100644 --- a/src/api/exception/error_categories.cpp +++ b/src/api/exception/error_categories.cpp @@ -47,16 +47,6 @@ 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() { @@ -68,9 +58,4 @@ 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; -} } diff --git a/src/api/metadata/condition_evaluator.cpp b/src/api/metadata/condition_evaluator.cpp index d16143a4..2b04961b 100644 --- a/src/api/metadata/condition_evaluator.cpp +++ b/src/api/metadata/condition_evaluator.cpp @@ -25,11 +25,10 @@ #include "api/metadata/condition_evaluator.h" #include +#include #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(std::string_view operation, int returnCode) { @@ -41,7 +40,7 @@ void HandleError(std::string_view operation, int returnCode) { std::string err; lci_get_error_message(&message); if (message == nullptr) { - err = fmt::format("Failed to {}. Error code: {}", operation, returnCode); + err = fmt::format("Failed to {}. loot-condition-interpreter error code: {}", operation, returnCode); } else { err = fmt::format("Failed to {}. Details: {}", operation, message); } @@ -51,8 +50,7 @@ void HandleError(std::string_view operation, int returnCode) { logger->error(err); } - throw ConditionSyntaxError( - returnCode, loot_condition_interpreter_category(), err); + throw std::runtime_error(err); } int mapGameType(GameType gameType) { diff --git a/src/tests/api/internals/metadata/condition_evaluator_test.h b/src/tests/api/internals/metadata/condition_evaluator_test.h index 9c0d07e7..93bed1e7 100644 --- a/src/tests/api/internals/metadata/condition_evaluator_test.h +++ b/src/tests/api/internals/metadata/condition_evaluator_test.h @@ -25,8 +25,9 @@ along with LOOT. If not, see #ifndef LOOT_TESTS_API_INTERNALS_METADATA_CONDITION_EVALUATOR_TEST #define LOOT_TESTS_API_INTERNALS_METADATA_CONDITION_EVALUATOR_TEST +#include + #include "api/metadata/condition_evaluator.h" -#include "loot/exception/condition_syntax_error.h" #include "tests/common_game_test_fixture.h" namespace loot { @@ -90,7 +91,7 @@ TEST_P(ConditionEvaluatorTest, } TEST_P(ConditionEvaluatorTest, evaluateShouldThrowForAnInvalidConditionString) { - EXPECT_THROW(evaluator_.Evaluate("condition"), ConditionSyntaxError); + EXPECT_THROW(evaluator_.Evaluate("condition"), std::runtime_error); } TEST_P(ConditionEvaluatorTest,