From 00be5fd206d877a4563a16d2109bd01b153241f3 Mon Sep 17 00:00:00 2001 From: Oliver Hamlet Date: Sat, 8 Oct 2016 09:37:59 +0100 Subject: [PATCH] Remove obsolete Error class --- CMakeLists.txt | 2 - docs/api/reference.rst | 12 +-- include/loot/api.h | 1 - include/loot/error.h | 91 ------------------- src/api/api.cpp | 1 - src/api/api_database.cpp | 1 - src/backend/app/loot_paths.cpp | 1 - src/backend/app/loot_state.cpp | 3 +- src/backend/game/game.cpp | 1 - src/backend/game/game_cache.cpp | 1 - src/backend/game/game_settings.cpp | 1 - src/backend/game/load_order_handler.cpp | 3 +- src/backend/helpers/git_helper.cpp | 1 - src/backend/helpers/helpers.cpp | 1 - src/backend/metadata/condition_evaluator.cpp | 1 - src/backend/metadata/condition_grammar.h | 1 - src/backend/metadata/message.cpp | 1 - src/backend/metadata/plugin_metadata.cpp | 1 - src/backend/metadata_list.cpp | 1 - src/backend/plugin/plugin_sorter.cpp | 1 - src/gui/query/clipboard_query.h | 1 - src/gui/query/editor_closed_query.h | 2 - src/gui/query/get_game_data_query.h | 3 +- src/gui/query/query.h | 5 - src/gui/query/sort_plugins_query.h | 2 +- src/gui/query/update_masterlist_query.h | 4 +- src/gui/query_handler.cpp | 1 - src/tests/backend/helpers/helpers_test.h | 1 - .../backend/metadata/condition_grammar_test.h | 1 - .../metadata/conditional_metadata_test.h | 1 - 30 files changed, 12 insertions(+), 135 deletions(-) delete mode 100644 include/loot/error.h diff --git a/CMakeLists.txt b/CMakeLists.txt index da2572c9..283ceaa1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -219,7 +219,6 @@ set (LOOT_HEADERS "${CMAKE_SOURCE_DIR}/src/backend/app/loot_paths.h" "${CMAKE_SOURCE_DIR}/src/backend/helpers/version.h" "${CMAKE_SOURCE_DIR}/src/backend/helpers/yaml_set_helpers.h" "${CMAKE_SOURCE_DIR}/include/loot/api_decorator.h" - "${CMAKE_SOURCE_DIR}/include/loot/error.h" "${CMAKE_SOURCE_DIR}/include/loot/error_categories.h" "${CMAKE_SOURCE_DIR}/include/loot/exception/condition_syntax_error.h" "${CMAKE_SOURCE_DIR}/include/loot/exception/cyclic_interaction_error.h" @@ -283,7 +282,6 @@ set (LOOT_API_SRC "${CMAKE_BINARY_DIR}/generated/loot_version.cpp" set (LOOT_API_HEADERS "${CMAKE_SOURCE_DIR}/include/loot/api.h" "${CMAKE_SOURCE_DIR}/include/loot/api_decorator.h" "${CMAKE_SOURCE_DIR}/include/loot/database_interface.h" - "${CMAKE_SOURCE_DIR}/include/loot/error.h" "${CMAKE_SOURCE_DIR}/include/loot/error_categories.h" "${CMAKE_SOURCE_DIR}/include/loot/exception/condition_syntax_error.h" "${CMAKE_SOURCE_DIR}/include/loot/exception/cyclic_interaction_error.h" diff --git a/docs/api/reference.rst b/docs/api/reference.rst index 0450adb7..f0b39013 100644 --- a/docs/api/reference.rst +++ b/docs/api/reference.rst @@ -43,6 +43,12 @@ Interfaces Classes ======= +.. doxygenclass:: loot::LootVersion + :members: + +Exceptions +========== + .. doxygenclass:: loot::CyclicInteractionError :members: @@ -58,12 +64,6 @@ Classes .. doxygenclass:: loot::FileAccessError :members: -.. doxygenclass:: loot::Error - :members: - -.. doxygenclass:: loot::LootVersion - :members: - Error Categories ================ diff --git a/include/loot/api.h b/include/loot/api.h index c27a9fa9..8f6fc8dd 100644 --- a/include/loot/api.h +++ b/include/loot/api.h @@ -30,7 +30,6 @@ #include "loot/api_decorator.h" #include "loot/database_interface.h" -#include "loot/error.h" #include "loot/error_categories.h" #include "loot/exception/condition_syntax_error.h" #include "loot/exception/cyclic_interaction_error.h" diff --git a/include/loot/error.h b/include/loot/error.h deleted file mode 100644 index a6248271..00000000 --- a/include/loot/error.h +++ /dev/null @@ -1,91 +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_ERROR -#define LOOT_ERROR - -#include -#include - -namespace loot { -/** - * @brief A class that defines the type of objects thrown as errors by the LOOT - * API. - * @details Note that not all exceptions thrown from the LOOT API use this type, - * so catch `std::exception` too. - */ -class Error : public std::exception { -public: - /** - * @brief A code indicating the type of error that occurred. - */ - enum struct Code : unsigned int { - /** - * No error occurred. This is used internally to indicate that an operation - * failed, but its failure was not fatal to the task being performed. - */ - ok = 0, - }; - - /** - * @brief Construct an error object giving a code and error message. - */ - Error(const Code code_arg, const std::string& what_arg) : code_(code_arg), what_(what_arg) {} - ~Error() throw() {}; - - /** - * @brief Get the code describing the type of error that occurred. - * @return An error code. - */ - Code code() const { return code_; } - - /** - * @brief A utility function that casts the code to an unsigned int. - * @return An error code's unsigned integer value. - */ - unsigned int codeAsUnsignedInt() const { - return asUnsignedInt(code_); - } - - /** - * @brief Get the message that describes the error details. - * @return A string describing the error that occurred. - */ - const char * what() const throw() { return what_.c_str(); } - - /** - * A utility function that converts a given error code to an unsigned int. - * @param code The code to convert. - * @return The error code's unsigned integer value. - */ - static unsigned int asUnsignedInt(Code code) { - return static_cast(code); - } -private: - Code code_; - std::string what_; -}; -} - -#endif diff --git a/src/api/api.cpp b/src/api/api.cpp index 9b24b909..1e08d730 100644 --- a/src/api/api.cpp +++ b/src/api/api.cpp @@ -28,7 +28,6 @@ #include #include "api/api_database.h" -#include "loot/error.h" #include "backend/app/loot_paths.h" namespace fs = boost::filesystem; diff --git a/src/api/api_database.cpp b/src/api/api_database.cpp index c722a26d..7a04f28f 100644 --- a/src/api/api_database.cpp +++ b/src/api/api_database.cpp @@ -27,7 +27,6 @@ #include #include -#include "loot/error.h" #include "loot/exception/file_access_error.h" #include "backend/game/game.h" #include "backend/plugin/plugin_sorter.h" diff --git a/src/backend/app/loot_paths.cpp b/src/backend/app/loot_paths.cpp index a64b1078..c8881cfe 100644 --- a/src/backend/app/loot_paths.cpp +++ b/src/backend/app/loot_paths.cpp @@ -28,7 +28,6 @@ Fallout: New Vegas. #include -#include "loot/error.h" #include "backend/helpers/helpers.h" #ifdef _WIN32 diff --git a/src/backend/app/loot_state.cpp b/src/backend/app/loot_state.cpp index 7e562ea7..42d79305 100644 --- a/src/backend/app/loot_state.cpp +++ b/src/backend/app/loot_state.cpp @@ -34,7 +34,6 @@ #include #include -#include "loot/error.h" #include "loot/exception/game_detection_error.h" #include "backend/app/loot_paths.h" #include "backend/helpers/helpers.h" @@ -189,7 +188,7 @@ void LootState::init(const std::string& cmdLineGame) { storeGameSettings(toGameSettings(games_)); } catch (GameDetectionError& e) { initErrors_.push_back(e.what()); - } catch (Error &e) { + } catch (std::exception& e) { BOOST_LOG_TRIVIAL(error) << "Game-specific settings could not be initialised. " << e.what(); initErrors_.push_back((format(translate("Error: Game-specific settings could not be initialised. %1%")) % e.what()).str()); } diff --git a/src/backend/game/game.cpp b/src/backend/game/game.cpp index 805877a4..1355d7ee 100644 --- a/src/backend/game/game.cpp +++ b/src/backend/game/game.cpp @@ -32,7 +32,6 @@ #include #include "backend/app/loot_paths.h" -#include "loot/error.h" #include "loot/exception/file_access_error.h" #include "loot/exception/game_detection_error.h" #include "backend/helpers/helpers.h" diff --git a/src/backend/game/game_cache.cpp b/src/backend/game/game_cache.cpp index 8f7b2e20..47868367 100644 --- a/src/backend/game/game_cache.cpp +++ b/src/backend/game/game_cache.cpp @@ -30,7 +30,6 @@ #include #include -#include "loot/error.h" #include "backend/helpers/helpers.h" using boost::locale::to_lower; diff --git a/src/backend/game/game_settings.cpp b/src/backend/game/game_settings.cpp index 153be713..a3f34623 100644 --- a/src/backend/game/game_settings.cpp +++ b/src/backend/game/game_settings.cpp @@ -29,7 +29,6 @@ #include #include "backend/app/loot_paths.h" -#include "loot/error.h" #include "backend/helpers/helpers.h" namespace fs = boost::filesystem; diff --git a/src/backend/game/load_order_handler.cpp b/src/backend/game/load_order_handler.cpp index 4e6b9913..da33fc10 100644 --- a/src/backend/game/load_order_handler.cpp +++ b/src/backend/game/load_order_handler.cpp @@ -28,7 +28,6 @@ #include #include -#include "loot/error.h" #include "loot/error_categories.h" using boost::locale::translate; @@ -182,7 +181,7 @@ void LoadOrderHandler::SetLoadOrder(const std::vector& loadOrder) c try { SetLoadOrder(pluginArr, pluginArrSize); - } catch (Error &/*e*/) { + } catch (std::exception& /*e*/) { for (size_t i = 0; i < pluginArrSize; i++) delete[] pluginArr[i]; delete[] pluginArr; diff --git a/src/backend/helpers/git_helper.cpp b/src/backend/helpers/git_helper.cpp index e94b732e..d865f27f 100644 --- a/src/backend/helpers/git_helper.cpp +++ b/src/backend/helpers/git_helper.cpp @@ -28,7 +28,6 @@ #include #include -#include "loot/error.h" #include "loot/error_categories.h" #include "loot/exception/git_state_error.h" diff --git a/src/backend/helpers/helpers.cpp b/src/backend/helpers/helpers.cpp index aeedd1fb..764ff5e8 100644 --- a/src/backend/helpers/helpers.cpp +++ b/src/backend/helpers/helpers.cpp @@ -40,7 +40,6 @@ #include #include -#include "loot/error.h" #include "loot/exception/file_access_error.h" #ifdef _WIN32 diff --git a/src/backend/metadata/condition_evaluator.cpp b/src/backend/metadata/condition_evaluator.cpp index c6199f61..df597aca 100644 --- a/src/backend/metadata/condition_evaluator.cpp +++ b/src/backend/metadata/condition_evaluator.cpp @@ -26,7 +26,6 @@ #include -#include "loot/error.h" #include "backend/helpers/helpers.h" namespace loot { diff --git a/src/backend/metadata/condition_grammar.h b/src/backend/metadata/condition_grammar.h index a598ec95..e5b6a578 100644 --- a/src/backend/metadata/condition_grammar.h +++ b/src/backend/metadata/condition_grammar.h @@ -46,7 +46,6 @@ #include #include -#include "loot/error.h" #include "loot/exception/condition_syntax_error.h" #include "backend/game/game.h" #include "backend/helpers/helpers.h" diff --git a/src/backend/metadata/message.cpp b/src/backend/metadata/message.cpp index 48cd6caf..0b6146ef 100644 --- a/src/backend/metadata/message.cpp +++ b/src/backend/metadata/message.cpp @@ -26,7 +26,6 @@ #include -#include "loot/error.h" #include "backend/game/game.h" #include "backend/helpers/language.h" diff --git a/src/backend/metadata/plugin_metadata.cpp b/src/backend/metadata/plugin_metadata.cpp index cb160f67..15b1d5ea 100644 --- a/src/backend/metadata/plugin_metadata.cpp +++ b/src/backend/metadata/plugin_metadata.cpp @@ -32,7 +32,6 @@ #include #include -#include "loot/error.h" #include "backend/game/game.h" #include "backend/helpers/helpers.h" diff --git a/src/backend/metadata_list.cpp b/src/backend/metadata_list.cpp index fe59e321..8cdcb642 100644 --- a/src/backend/metadata_list.cpp +++ b/src/backend/metadata_list.cpp @@ -28,7 +28,6 @@ #include #include -#include "loot/error.h" #include "loot/exception/file_access_error.h" #include "backend/game/game.h" diff --git a/src/backend/plugin/plugin_sorter.cpp b/src/backend/plugin/plugin_sorter.cpp index abb54230..cf814c31 100644 --- a/src/backend/plugin/plugin_sorter.cpp +++ b/src/backend/plugin/plugin_sorter.cpp @@ -34,7 +34,6 @@ #include #include -#include "loot/error.h" #include "loot/exception/cyclic_interaction_error.h" #include "backend/game/game.h" #include "backend/helpers/helpers.h" diff --git a/src/gui/query/clipboard_query.h b/src/gui/query/clipboard_query.h index 3650f87b..a2f9e550 100644 --- a/src/gui/query/clipboard_query.h +++ b/src/gui/query/clipboard_query.h @@ -27,7 +27,6 @@ along with LOOT. If not, see #include "backend/helpers/helpers.h" #include "gui/query/query.h" -#include "loot/error.h" namespace loot { class ClipboardQuery : public Query { diff --git a/src/gui/query/editor_closed_query.h b/src/gui/query/editor_closed_query.h index 5e1a3db9..320a3487 100644 --- a/src/gui/query/editor_closed_query.h +++ b/src/gui/query/editor_closed_query.h @@ -41,8 +41,6 @@ public: state_.decrementUnappliedChangeCounter(); return json; - } catch (Error&) { - throw; } catch (std::exception& e) { // If this was a YAML conversion error, cut off the line and column numbers, // since the YAML wasn't written to a file. diff --git a/src/gui/query/get_game_data_query.h b/src/gui/query/get_game_data_query.h index f111e50a..ddcaad25 100644 --- a/src/gui/query/get_game_data_query.h +++ b/src/gui/query/get_game_data_query.h @@ -27,7 +27,6 @@ along with LOOT. If not, see #include -#include "loot/error.h" #include "loot/loot_version.h" #include "backend/helpers/json.h" #include "backend/helpers/version.h" @@ -113,7 +112,7 @@ private: Masterlist::Info info = state_.getCurrentGame().GetMasterlist().GetInfo(state_.getCurrentGame().MasterlistPath(), true); masterlistNode["revision"] = info.revision; masterlistNode["date"] = info.date; - } catch (Error &e) { + } catch (std::exception &e) { masterlistNode["revision"] = e.what(); masterlistNode["date"] = e.what(); } diff --git a/src/gui/query/query.h b/src/gui/query/query.h index b10861bd..18fa4692 100644 --- a/src/gui/query/query.h +++ b/src/gui/query/query.h @@ -28,17 +28,12 @@ along with LOOT. If not, see #include #include -#include "loot/error.h" - namespace loot { class Query : public CefBase { public: void execute(CefRefPtr callback) { try { callback->Success(executeLogic()); - } catch (Error &e) { - BOOST_LOG_TRIVIAL(error) << e.what(); - callback->Failure(e.codeAsUnsignedInt(), e.what()); } catch (std::exception &e) { BOOST_LOG_TRIVIAL(error) << e.what(); callback->Failure(-1, e.what()); diff --git a/src/gui/query/sort_plugins_query.h b/src/gui/query/sort_plugins_query.h index e526b731..dcc6e70b 100644 --- a/src/gui/query/sort_plugins_query.h +++ b/src/gui/query/sort_plugins_query.h @@ -73,7 +73,7 @@ private: } catch (CyclicInteractionError& e) { BOOST_LOG_TRIVIAL(error) << "Failed to sort plugins. Details: " << e.what(); state_.getCurrentGame().AppendMessage(Message(MessageType::error, e.what())); - } catch (Error& e) { + } catch (std::exception& e) { BOOST_LOG_TRIVIAL(error) << "Failed to sort plugins. Details: " << e.what(); } diff --git a/src/gui/query/update_masterlist_query.h b/src/gui/query/update_masterlist_query.h index 1d40867f..db2c42dd 100644 --- a/src/gui/query/update_masterlist_query.h +++ b/src/gui/query/update_masterlist_query.h @@ -50,7 +50,7 @@ private: bool updateMasterlist() { try { return game_.GetMasterlist().Update(game_); - } catch (Error &e) { + } catch (std::exception& e) { try { game_.GetMasterlist().Load(game_.MasterlistPath()); } catch (...) {} @@ -80,7 +80,7 @@ private: Masterlist::Info info = game_.GetMasterlist().GetInfo(game_.MasterlistPath(), true); gameMetadata["masterlist"]["revision"] = info.revision; gameMetadata["masterlist"]["date"] = info.date; - } catch (Error &e) { + } catch (std::exception& e) { gameMetadata["masterlist"]["revision"] = e.what(); gameMetadata["masterlist"]["date"] = e.what(); } diff --git a/src/gui/query_handler.cpp b/src/gui/query_handler.cpp index bee78c5c..59b8b7cc 100644 --- a/src/gui/query_handler.cpp +++ b/src/gui/query_handler.cpp @@ -70,7 +70,6 @@ #include "gui/resource.h" #include "gui/yaml_simple_message_helpers.h" -#include "loot/error.h" #include "backend/app/loot_paths.h" #include "backend/plugin/plugin_sorter.h" #include "backend/helpers/helpers.h" diff --git a/src/tests/backend/helpers/helpers_test.h b/src/tests/backend/helpers/helpers_test.h index 6cf4e7d5..66974daf 100644 --- a/src/tests/backend/helpers/helpers_test.h +++ b/src/tests/backend/helpers/helpers_test.h @@ -27,7 +27,6 @@ along with LOOT. If not, see #include "backend/helpers/helpers.h" -#include "loot/error.h" #include "loot/exception/file_access_error.h" #include "tests/common_game_test_fixture.h" diff --git a/src/tests/backend/metadata/condition_grammar_test.h b/src/tests/backend/metadata/condition_grammar_test.h index 06ffb048..4da2b8fa 100644 --- a/src/tests/backend/metadata/condition_grammar_test.h +++ b/src/tests/backend/metadata/condition_grammar_test.h @@ -27,7 +27,6 @@ along with LOOT. If not, see #include "backend/metadata/condition_grammar.h" -#include "loot/error.h" #include "tests/common_game_test_fixture.h" namespace loot { diff --git a/src/tests/backend/metadata/conditional_metadata_test.h b/src/tests/backend/metadata/conditional_metadata_test.h index c9be17c7..5507acd3 100644 --- a/src/tests/backend/metadata/conditional_metadata_test.h +++ b/src/tests/backend/metadata/conditional_metadata_test.h @@ -27,7 +27,6 @@ along with LOOT. If not, see #include "backend/metadata/conditional_metadata.h" -#include "loot/error.h" #include "tests/common_game_test_fixture.h" namespace loot {