diff --git a/repak/src/error.rs b/repak/src/error.rs index a669106..affffae 100644 --- a/repak/src/error.rs +++ b/repak/src/error.rs @@ -13,6 +13,9 @@ pub enum Error { #[error("io error: {0}")] Io(#[from] std::io::Error), + #[error("fmt error: {0}")] + Fmt(#[from] std::fmt::Error), + #[error("utf8 conversion: {0}")] Utf8(#[from] std::string::FromUtf8Error), @@ -68,8 +71,8 @@ pub enum Error { #[error("error with OsString")] OsString(std::ffi::OsString), - #[error("version unsupported or is encrypted (possibly missing --aes-key?)")] - UnsuportedOrEncrypted, + #[error("{0}version unsupported or is encrypted (possibly missing --aes-key?)")] + UnsuportedOrEncrypted(String), #[error("{0}")] Other(String), diff --git a/repak/src/pak.rs b/repak/src/pak.rs index ceddc09..fd86da5 100644 --- a/repak/src/pak.rs +++ b/repak/src/pak.rs @@ -83,15 +83,21 @@ impl PakReader { mut reader: R, key: Option, ) -> Result { + use std::fmt::Write; + let mut log = "\n".to_owned(); + for ver in Version::iter() { match Pak::read(&mut reader, ver, key.clone()) { Ok(pak) => { return Ok(PakReader { pak, key }); } - _ => continue, + Err(err) => { + writeln!(log, "trying version {} failed: {}", ver, err)?; + continue; + } } } - Err(super::Error::UnsuportedOrEncrypted) + Err(super::Error::UnsuportedOrEncrypted(log)) } pub fn version(&self) -> super::Version {