mirror of
https://github.com/loot/loot-condition-interpreter.git
synced 2026-07-27 14:16:09 -07:00
Implement the Error trait on the Error enum
This commit is contained in:
+26
@@ -12,6 +12,7 @@ mod function;
|
|||||||
mod version;
|
mod version;
|
||||||
|
|
||||||
use std::collections::{HashMap, HashSet};
|
use std::collections::{HashMap, HashSet};
|
||||||
|
use std::error;
|
||||||
use std::ffi::OsStr;
|
use std::ffi::OsStr;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use std::io;
|
use std::io;
|
||||||
@@ -46,6 +47,31 @@ impl From<io::Error> for Error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl fmt::Display for Error {
|
||||||
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
|
match self {
|
||||||
|
Error::ParsingIncomplete => write!(f, "More input was expected by the parser"),
|
||||||
|
Error::ParsingError => {
|
||||||
|
write!(f, "An error was encountered while parsing the expression")
|
||||||
|
}
|
||||||
|
Error::PeParsingError => write!(
|
||||||
|
f,
|
||||||
|
"An error was encountered while reading the version of an executable"
|
||||||
|
),
|
||||||
|
Error::IoError(e) => e.fmt(f),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl error::Error for Error {
|
||||||
|
fn cause(&self) -> Option<&error::Error> {
|
||||||
|
match self {
|
||||||
|
Error::IoError(e) => Some(e),
|
||||||
|
_ => None,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
|
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
|
||||||
pub enum GameType {
|
pub enum GameType {
|
||||||
Tes4,
|
Tes4,
|
||||||
|
|||||||
Reference in New Issue
Block a user