Remove FileAccessError

It wasn't usefully different from just throwing std::runtime_error.
This commit is contained in:
Oliver Hamlet
2025-06-08 17:58:27 +01:00
parent 328f1a2c15
commit fe3e2b2711
9 changed files with 11 additions and 78 deletions
-1
View File
@@ -92,7 +92,6 @@ set(LIBLOOT_INCLUDE_H_FILES
"${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/file_access_error.h"
"${CMAKE_SOURCE_DIR}/include/loot/exception/undefined_group_error.h"
"${CMAKE_SOURCE_DIR}/include/loot/enum/edge_type.h"
"${CMAKE_SOURCE_DIR}/include/loot/enum/game_type.h"
+1 -1
View File
@@ -89,5 +89,5 @@ For the first layer of the wrapper, built using Cargo:
For the ABI-compatible second layer of the wrapper, built using CMake:
- Some exceptions have changed type: they all still derive from `std::exception`, but for example some `std::logic_error` and `std::invalid_argument` exceptions have become `std::runtime_error` and `FileAccessError` exceptions, some `YAML::RepresentationException` exceptions have become `FileAccessError` exceptions, etc.
- Some exceptions have changed type: they all still derive from `std::exception`, but for example some `std::logic_error` and `std::invalid_argument` exceptions have become `std::runtime_error` exceptions, some `YAML::RepresentationException` exceptions have become `FileAccessError` exceptions, etc.
- Exception messages are generally not expected to be the same between the two implementations.
-3
View File
@@ -98,9 +98,6 @@ Exceptions
.. doxygenclass:: loot::ConditionSyntaxError
:members:
.. doxygenclass:: loot::FileAccessError
:members:
.. doxygenclass:: loot::UndefinedGroupError
:members:
-1
View File
@@ -37,7 +37,6 @@
#include "loot/exception/condition_syntax_error.h"
#include "loot/exception/cyclic_interaction_error.h"
#include "loot/exception/error_categories.h"
#include "loot/exception/file_access_error.h"
#include "loot/exception/undefined_group_error.h"
#include "loot/game_interface.h"
#include "loot/loot_version.h"
@@ -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
<https://www.gnu.org/licenses/>.
*/
#ifndef LOOT_EXCEPTION_FILE_ACCESS_ERROR
#define LOOT_EXCEPTION_FILE_ACCESS_ERROR
#include <stdexcept>
namespace loot {
/**
* @brief An exception class thrown if an error is encountered while reading or
* writing a file.
*/
class FileAccessError : public std::runtime_error {
public:
using std::runtime_error::runtime_error;
};
}
#endif
-8
View File
@@ -5,7 +5,6 @@
#include "loot/exception/condition_syntax_error.h"
#include "loot/exception/cyclic_interaction_error.h"
#include "loot/exception/error_categories.h"
#include "loot/exception/file_access_error.h"
#include "loot/exception/undefined_group_error.h"
#include "loot/vertex.h"
@@ -20,7 +19,6 @@ constexpr std::string_view UNDEFINED_GROUP_ERROR_PREFIX =
constexpr std::string_view ESPLUGIN_ERROR_PREFIX = "EspluginError: "sv;
constexpr std::string_view LIBLOADORDER_ERROR_PREFIX = "LibloadorderError: "sv;
constexpr std::string_view LCI_ERROR_PREFIX = "LciError: "sv;
constexpr std::string_view FILE_ACCESS_ERROR_PREFIX = "FileAccessError: "sv;
constexpr std::string_view INVALID_ARGUMENT_PREFIX = "InvalidArgument: "sv;
bool startsWith(std::string_view str, std::string_view prefix) {
@@ -161,12 +159,6 @@ std::exception_ptr mapError(const ::rust::Error& error) {
return std::make_exception_ptr(ConditionSyntaxError(
code, loot_condition_interpreter_category(), details));
} else if (startsWith(error.what(), FILE_ACCESS_ERROR_PREFIX)) {
return std::make_exception_ptr(
FileAccessError(getErrorSuffix(error.what())));
} else if (startsWith(error.what(), FILE_ACCESS_ERROR_PREFIX)) {
return std::make_exception_ptr(
FileAccessError(getErrorSuffix(error.what())));
} else if (startsWith(error.what(), INVALID_ARGUMENT_PREFIX)) {
return std::make_exception_ptr(
std::invalid_argument(getErrorSuffix(error.what())));
+2 -15
View File
@@ -20,7 +20,6 @@ pub enum VerboseError {
CyclicInteractionError(Vec<libloot::Vertex>),
UndefinedGroupError(String),
SystemError(SystemError),
FileAccessError(String),
InvalidArgument(String),
Other(Box<dyn std::error::Error>),
}
@@ -51,7 +50,6 @@ impl std::fmt::Display for VerboseError {
};
write!(f, "{}: {}: {}", prefix, e.code(), e.message())
}
Self::FileAccessError(s) => write!(f, "FileAccessError: {s}"),
Self::InvalidArgument(s) => write!(f, "InvalidArgument: {s}"),
Self::Other(e) => fmt_error_chain(e.as_ref(), f),
}
@@ -63,6 +61,8 @@ variant_box_from_error!(NotValidUtf8, VerboseError::Other);
variant_box_from_error!(DatabaseLockPoisonError, VerboseError::Other);
variant_box_from_error!(MultilingualMessageContentsError, VerboseError::Other);
variant_box_from_error!(RegexError, VerboseError::Other);
variant_box_from_error!(LoadMetadataError, VerboseError::Other);
variant_box_from_error!(WriteMetadataError, VerboseError::Other);
impl From<GameHandleCreationError> for VerboseError {
fn from(value: GameHandleCreationError) -> Self {
@@ -89,7 +89,6 @@ impl From<LoadPluginsError> for VerboseError {
impl From<SortPluginsError> for VerboseError {
fn from(value: SortPluginsError) -> Self {
match value {
SortPluginsError::MetadataRetrievalError(e) => e.into(),
SortPluginsError::UndefinedGroup(g) => Self::UndefinedGroupError(g),
SortPluginsError::CycleFound(cycle) => Self::CyclicInteractionError(cycle),
SortPluginsError::PluginDataError(e) => e.into(),
@@ -117,18 +116,6 @@ impl From<LoadOrderError> for VerboseError {
}
}
impl From<LoadMetadataError> for VerboseError {
fn from(value: LoadMetadataError) -> Self {
Self::FileAccessError(value.to_string())
}
}
impl From<WriteMetadataError> for VerboseError {
fn from(value: WriteMetadataError) -> Self {
Self::FileAccessError(value.to_string())
}
}
impl From<ConditionEvaluationError> for VerboseError {
fn from(value: ConditionEvaluationError) -> Self {
Self::SystemError(SystemError::from(value))
@@ -127,7 +127,7 @@ TEST_P(DatabaseInterfaceTest,
TEST_P(DatabaseInterfaceTest,
loadMasterlistShouldThrowIfNoMasterlistIsPresent) {
EXPECT_THROW(handle_->GetDatabase().LoadMasterlist(masterlistPath),
FileAccessError);
std::runtime_error);
}
TEST_P(DatabaseInterfaceTest,
@@ -146,7 +146,7 @@ TEST_P(
EXPECT_THROW(handle_->GetDatabase().LoadMasterlistWithPrelude(masterlistPath,
preludePath),
FileAccessError);
std::runtime_error);
}
TEST_P(
@@ -185,7 +185,7 @@ TEST_P(DatabaseInterfaceTest,
loadUserlistShouldThrowIfAUserlistDoesNotExistAtTheGivenPath) {
ASSERT_NO_THROW(GenerateMasterlist());
EXPECT_THROW(handle_->GetDatabase().LoadUserlist(userlistPath_),
FileAccessError);
std::runtime_error);
}
TEST_P(DatabaseInterfaceTest, loadUserlistShouldSucceedIfTheUserlistIsPresent) {
@@ -204,7 +204,7 @@ TEST_P(
EXPECT_THROW(
handle_->GetDatabase().WriteUserMetadata(minimalOutputPath_, false),
FileAccessError);
std::runtime_error);
}
TEST_P(
@@ -238,7 +238,7 @@ TEST_P(DatabaseInterfaceTest,
EXPECT_THROW(
handle_->GetDatabase().WriteUserMetadata(minimalOutputPath_, true),
FileAccessError);
std::runtime_error);
}
TEST_P(DatabaseInterfaceTest,
@@ -753,7 +753,7 @@ TEST_P(
EXPECT_THROW(
handle_->GetDatabase().WriteMinimalList(minimalOutputPath_, false),
FileAccessError);
std::runtime_error);
}
TEST_P(
@@ -787,7 +787,7 @@ TEST_P(DatabaseInterfaceTest,
EXPECT_THROW(
handle_->GetDatabase().WriteMinimalList(minimalOutputPath_, true),
FileAccessError);
std::runtime_error);
}
TEST_P(DatabaseInterfaceTest,