mirror of
https://github.com/loot/libloot.git
synced 2026-07-27 14:16:01 -07:00
Remove FileAccessError
It wasn't usefully different from just throwing std::runtime_error.
This commit is contained in:
@@ -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
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user