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:
@@ -1,34 +0,0 @@
|
||||
// Unless otherwise noted, these constants and the mapping logic are copied from
|
||||
// loot-condition-interpreter-ffi.
|
||||
|
||||
use loot_condition_interpreter::Error;
|
||||
use std::ffi::c_int;
|
||||
|
||||
/// Something went wrong while parsing the condition expression.
|
||||
const LCI_ERROR_PARSING_ERROR: c_int = -2;
|
||||
|
||||
/// Something went wrong while getting the version of an executable.
|
||||
const LCI_ERROR_PE_PARSING_ERROR: c_int = -3;
|
||||
|
||||
/// Some sort of I/O error occurred.
|
||||
const LCI_ERROR_IO_ERROR: c_int = -4;
|
||||
|
||||
/// The library encountered an error that should not have been possible to
|
||||
/// encounter.
|
||||
const LCI_ERROR_INTERNAL_LOGIC_ERROR: c_int = -8;
|
||||
|
||||
// This constant is not copied from loot-condition-interpreter-ffi, but does not
|
||||
// conflict with any values defined there.
|
||||
pub(crate) const LCI_ERROR_UNKNOWN: c_int = c_int::MAX;
|
||||
|
||||
#[must_use]
|
||||
pub(crate) fn map_error(err: &Error) -> c_int {
|
||||
match err {
|
||||
Error::ParsingIncomplete(_) | Error::UnconsumedInput(_) | Error::ParsingError(_, _) => {
|
||||
LCI_ERROR_PARSING_ERROR
|
||||
}
|
||||
Error::PeParsingError(_, _) => LCI_ERROR_PE_PARSING_ERROR,
|
||||
Error::IoError(_, _) => LCI_ERROR_IO_ERROR,
|
||||
_ => LCI_ERROR_INTERNAL_LOGIC_ERROR,
|
||||
}
|
||||
}
|
||||
+1
-22
@@ -94,10 +94,9 @@
|
||||
)]
|
||||
use std::{error::Error, ffi::c_int};
|
||||
|
||||
use libloot::error::{ConditionEvaluationError, LoadOrderError, PluginDataError};
|
||||
use libloot::error::{LoadOrderError, PluginDataError};
|
||||
|
||||
mod esplugin;
|
||||
mod lci;
|
||||
mod libloadorder;
|
||||
|
||||
// It's important for API stability that these variants' values don't change.
|
||||
@@ -107,7 +106,6 @@ mod libloadorder;
|
||||
pub enum SystemErrorCategory {
|
||||
Esplugin = 1,
|
||||
Libloadorder = 2,
|
||||
LootConditionInterpreter = 3,
|
||||
}
|
||||
|
||||
impl std::fmt::Display for SystemErrorCategory {
|
||||
@@ -115,9 +113,6 @@ impl std::fmt::Display for SystemErrorCategory {
|
||||
match self {
|
||||
SystemErrorCategory::Esplugin => write!(f, "esplugin"),
|
||||
SystemErrorCategory::Libloadorder => write!(f, "libloadorder"),
|
||||
SystemErrorCategory::LootConditionInterpreter => {
|
||||
write!(f, "loot-condition-interpreter")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -190,22 +185,6 @@ impl From<LoadOrderError> for SystemError {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<ConditionEvaluationError> for SystemError {
|
||||
fn from(value: ConditionEvaluationError) -> Self {
|
||||
const LCI_ERROR_UNKNOWN: (i32, &str) = (
|
||||
lci::LCI_ERROR_UNKNOWN,
|
||||
"Could not retrieve loot-condition-interpreter error message",
|
||||
);
|
||||
|
||||
from_error(
|
||||
value,
|
||||
SystemErrorCategory::LootConditionInterpreter,
|
||||
LCI_ERROR_UNKNOWN,
|
||||
crate::lci::map_error,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
fn from_error<U: Error, V: Error + 'static, F: Fn(&V) -> c_int>(
|
||||
error: U,
|
||||
category: SystemErrorCategory,
|
||||
|
||||
Reference in New Issue
Block a user