mirror of
https://github.com/ouch-org/ouch.git
synced 2025-06-06 19:45:29 +00:00
fix: replace UnsupportedFormat error with UnrarError
Update error handling for unrar-specific issues to use the new UnrarError type.
This commit is contained in:
parent
7e830d9f53
commit
9c69fbd911
@ -61,7 +61,7 @@ pub fn list_archive(
|
|||||||
|
|
||||||
Ok(FileInArchive { path, is_dir })
|
Ok(FileInArchive { path, is_dir })
|
||||||
}).collect::<Vec<_>>().into_iter(),
|
}).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(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,6 +41,8 @@ pub enum Error {
|
|||||||
UnsupportedFormat { reason: String },
|
UnsupportedFormat { reason: String },
|
||||||
/// Invalid password provided
|
/// Invalid password provided
|
||||||
InvalidPassword(&'static str),
|
InvalidPassword(&'static str),
|
||||||
|
/// UnrarError From unrar::error::UnrarError
|
||||||
|
UnrarError { reason: String },
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Alias to std's Result with ouch's Error
|
/// 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())
|
FinalError::with_title("Recognised but unsupported format").detail(reason.clone())
|
||||||
}
|
}
|
||||||
Error::InvalidPassword(reason) => FinalError::with_title("Invalid password").detail(*reason),
|
Error::InvalidPassword(reason) => FinalError::with_title("Invalid password").detail(*reason),
|
||||||
|
Error::UnrarError{reason} => FinalError::with_title("Unrar error").detail(reason.clone()),
|
||||||
};
|
};
|
||||||
|
|
||||||
write!(f, "{err}")
|
write!(f, "{err}")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user