Skip to content

Commit

Permalink
Improving permission denied error message
Browse files Browse the repository at this point in the history
  • Loading branch information
marcospb19 committed Oct 29, 2021
1 parent 2512679 commit ae5d05f
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ pub enum Error {
FileNotFound(PathBuf),
AlreadyExists,
InvalidZipArchive(&'static str),
PermissionDenied,
PermissionDenied { error_title: String },
UnsupportedZipArchive(&'static str),
InternalError,
OofError(oof::OofError),
Expand Down Expand Up @@ -156,7 +156,9 @@ impl fmt::Display for Error {
Error::UnknownExtensionError(_) => todo!(),
Error::AlreadyExists => todo!(),
Error::InvalidZipArchive(_) => todo!(),
Error::PermissionDenied => todo!(),
Error::PermissionDenied { error_title } => {
FinalError::with_title(error_title).detail("Permission denied").to_owned()
}
Error::UnsupportedZipArchive(_) => todo!(),
Error::Custom { reason } => reason.clone(),
};
Expand All @@ -174,8 +176,8 @@ impl Error {
impl From<std::io::Error> for Error {
fn from(err: std::io::Error) -> Self {
match err.kind() {
std::io::ErrorKind::NotFound => panic!("{}", err),
std::io::ErrorKind::PermissionDenied => Self::PermissionDenied,
std::io::ErrorKind::NotFound => todo!(),
std::io::ErrorKind::PermissionDenied => Self::PermissionDenied { error_title: err.to_string() },
std::io::ErrorKind::AlreadyExists => Self::AlreadyExists,
_other => Self::IoError { reason: err.to_string() },
}
Expand Down

0 comments on commit ae5d05f

Please sign in to comment.