fix: replace UnsupportedFormat error with UnrarError

Update error handling for unrar-specific issues to use the new UnrarError type.
This commit is contained in:
ttyS3 2024-09-06 15:06:40 +00:00 committed by João Marcos
parent 7e830d9f53
commit 9c69fbd911
2 changed files with 4 additions and 1 deletions

View File

@ -61,7 +61,7 @@ pub fn list_archive(
Ok(FileInArchive { path, is_dir })
}).collect::<Vec<_>>().into_iter(),
Err(e) => vec![Err(Error::UnsupportedFormat {reason:e.to_string()})].into_iter(),
Err(e) => vec![Err(Error::UnrarError{reason: e.to_string()})].into_iter(),
}
}

View File

@ -41,6 +41,8 @@ pub enum Error {
UnsupportedFormat { reason: String },
/// Invalid password provided
InvalidPassword(&'static str),
/// UnrarError From unrar::error::UnrarError
UnrarError { reason: String },
}
/// Alias to std's Result with ouch's Error
@ -151,6 +153,7 @@ impl fmt::Display for Error {
FinalError::with_title("Recognised but unsupported format").detail(reason.clone())
}
Error::InvalidPassword(reason) => FinalError::with_title("Invalid password").detail(*reason),
Error::UnrarError{reason} => FinalError::with_title("Unrar error").detail(reason.clone()),
};
write!(f, "{err}")