mirror of
https://github.com/xavo95/repak.git
synced 2025-01-18 19:04:07 +00:00
When failing to parse, show error for each checked version
This commit is contained in:
parent
ad22ba9b1a
commit
2de7924198
2 changed files with 13 additions and 4 deletions
|
@ -13,6 +13,9 @@ pub enum Error {
|
||||||
#[error("io error: {0}")]
|
#[error("io error: {0}")]
|
||||||
Io(#[from] std::io::Error),
|
Io(#[from] std::io::Error),
|
||||||
|
|
||||||
|
#[error("fmt error: {0}")]
|
||||||
|
Fmt(#[from] std::fmt::Error),
|
||||||
|
|
||||||
#[error("utf8 conversion: {0}")]
|
#[error("utf8 conversion: {0}")]
|
||||||
Utf8(#[from] std::string::FromUtf8Error),
|
Utf8(#[from] std::string::FromUtf8Error),
|
||||||
|
|
||||||
|
@ -68,8 +71,8 @@ pub enum Error {
|
||||||
#[error("error with OsString")]
|
#[error("error with OsString")]
|
||||||
OsString(std::ffi::OsString),
|
OsString(std::ffi::OsString),
|
||||||
|
|
||||||
#[error("version unsupported or is encrypted (possibly missing --aes-key?)")]
|
#[error("{0}version unsupported or is encrypted (possibly missing --aes-key?)")]
|
||||||
UnsuportedOrEncrypted,
|
UnsuportedOrEncrypted(String),
|
||||||
|
|
||||||
#[error("{0}")]
|
#[error("{0}")]
|
||||||
Other(String),
|
Other(String),
|
||||||
|
|
|
@ -83,15 +83,21 @@ impl PakReader {
|
||||||
mut reader: R,
|
mut reader: R,
|
||||||
key: Option<aes::Aes256>,
|
key: Option<aes::Aes256>,
|
||||||
) -> Result<Self, super::Error> {
|
) -> Result<Self, super::Error> {
|
||||||
|
use std::fmt::Write;
|
||||||
|
let mut log = "\n".to_owned();
|
||||||
|
|
||||||
for ver in Version::iter() {
|
for ver in Version::iter() {
|
||||||
match Pak::read(&mut reader, ver, key.clone()) {
|
match Pak::read(&mut reader, ver, key.clone()) {
|
||||||
Ok(pak) => {
|
Ok(pak) => {
|
||||||
return Ok(PakReader { pak, key });
|
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 {
|
pub fn version(&self) -> super::Version {
|
||||||
|
|
Loading…
Reference in a new issue