mirror of
https://github.com/loot/libloot.git
synced 2026-07-27 14:16:01 -07:00
Remove ConditionSyntaxError
It's not usefully different from throwing std::runtime_error.
This commit is contained in:
@@ -90,7 +90,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"
|
||||
|
||||
@@ -95,9 +95,6 @@ Exceptions
|
||||
.. doxygenclass:: loot::CyclicInteractionError
|
||||
:members:
|
||||
|
||||
.. doxygenclass:: loot::ConditionSyntaxError
|
||||
:members:
|
||||
|
||||
.. doxygenclass:: loot::UndefinedGroupError
|
||||
:members:
|
||||
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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_CONDITION_SYNTAX_ERROR
|
||||
#define LOOT_EXCEPTION_CONDITION_SYNTAX_ERROR
|
||||
|
||||
#include <system_error>
|
||||
|
||||
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
|
||||
@@ -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
|
||||
|
||||
@@ -47,20 +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() {
|
||||
@@ -72,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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
#include <charconv>
|
||||
|
||||
#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"
|
||||
@@ -18,7 +17,6 @@ constexpr std::string_view UNDEFINED_GROUP_ERROR_PREFIX =
|
||||
"UndefinedGroupError: "sv;
|
||||
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 INVALID_ARGUMENT_PREFIX = "InvalidArgument: "sv;
|
||||
|
||||
bool startsWith(std::string_view str, std::string_view prefix) {
|
||||
@@ -153,12 +151,6 @@ std::exception_ptr mapError(const ::rust::Error& error) {
|
||||
|
||||
return std::make_exception_ptr(
|
||||
std::system_error(code, libloadorder_category(), details));
|
||||
} else if (startsWith(error.what(), LCI_ERROR_PREFIX)) {
|
||||
const auto [code, details] = parseSystemError(
|
||||
std::string_view(error.what()).substr(LCI_ERROR_PREFIX.size()));
|
||||
|
||||
return std::make_exception_ptr(ConditionSyntaxError(
|
||||
code, loot_condition_interpreter_category(), details));
|
||||
} else if (startsWith(error.what(), INVALID_ARGUMENT_PREFIX)) {
|
||||
return std::make_exception_ptr(
|
||||
std::invalid_argument(getErrorSuffix(error.what())));
|
||||
|
||||
+2
-16
@@ -45,7 +45,6 @@ impl std::fmt::Display for VerboseError {
|
||||
let prefix = match e.category() {
|
||||
SystemErrorCategory::Esplugin => "EspluginError",
|
||||
SystemErrorCategory::Libloadorder => "LibloadorderError",
|
||||
SystemErrorCategory::LootConditionInterpreter => "LciError",
|
||||
_ => "UnknownCategoryError",
|
||||
};
|
||||
write!(f, "{}: {}: {}", prefix, e.code(), e.message())
|
||||
@@ -63,6 +62,8 @@ 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);
|
||||
variant_box_from_error!(ConditionEvaluationError, VerboseError::Other);
|
||||
variant_box_from_error!(MetadataRetrievalError, VerboseError::Other);
|
||||
|
||||
impl From<GameHandleCreationError> for VerboseError {
|
||||
fn from(value: GameHandleCreationError) -> Self {
|
||||
@@ -116,12 +117,6 @@ impl From<LoadOrderError> for VerboseError {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<ConditionEvaluationError> for VerboseError {
|
||||
fn from(value: ConditionEvaluationError) -> Self {
|
||||
Self::SystemError(SystemError::from(value))
|
||||
}
|
||||
}
|
||||
|
||||
impl From<GroupsPathError> for VerboseError {
|
||||
fn from(value: GroupsPathError) -> Self {
|
||||
match value {
|
||||
@@ -132,15 +127,6 @@ impl From<GroupsPathError> for VerboseError {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<MetadataRetrievalError> for VerboseError {
|
||||
fn from(value: MetadataRetrievalError) -> Self {
|
||||
match value {
|
||||
MetadataRetrievalError::ConditionEvaluationError(e) => e.into(),
|
||||
MetadataRetrievalError::RegexError(_) | _ => Self::Other(Box::new(value)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<PluginDataError> for VerboseError {
|
||||
fn from(value: PluginDataError) -> Self {
|
||||
Self::SystemError(SystemError::from(value))
|
||||
|
||||
Reference in New Issue
Block a user