diff --git a/src/error.rs b/src/error.rs index bce745e..2c9a417 100644 --- a/src/error.rs +++ b/src/error.rs @@ -20,13 +20,14 @@ use std::error; use std::fmt; use std::io; +use std::path::PathBuf; use nom::Err; #[derive(Debug)] pub enum Error { IoError(io::Error), - NoFilename, + NoFilename(PathBuf), ParsingIncomplete, ParsingError(Vec, ParsingErrorKind), DecodeError(Vec), @@ -53,8 +54,8 @@ impl From for Error { impl fmt::Display for Error { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match self { - Error::IoError(ref x) => x.fmt(f), - Error::NoFilename => write!(f, "The plugin path has no filename part"), + Error::IoError(x) => x.fmt(f), + Error::NoFilename(path) => write!(f, "The plugin path {path:?} has no filename part"), Error::ParsingIncomplete => write!(f, "More input was expected by the plugin parser"), Error::ParsingError(input, kind) => write!( f, diff --git a/src/plugin.rs b/src/plugin.rs index 276e318..de48b80 100644 --- a/src/plugin.rs +++ b/src/plugin.rs @@ -107,7 +107,7 @@ impl Plugin { pub fn parse(&mut self, input: &[u8], load_header_only: bool) -> Result<(), Error> { match self.filename() { - None => Err(Error::NoFilename), + None => Err(Error::NoFilename(self.path.clone())), Some(filename) => { self.data = parse_plugin(input, self.game_id, &filename, load_header_only)?.1; @@ -123,7 +123,7 @@ impl Plugin { expected_header_type: &'static [u8], ) -> Result<(), Error> { match self.filename() { - None => Err(Error::NoFilename), + None => Err(Error::NoFilename(self.path.clone())), Some(filename) => { self.data = read_plugin( &mut reader,