mirror of
https://github.com/ouch-org/ouch.git
synced 2025-06-06 19:45:29 +00:00
Improving permission denied error message
This commit is contained in:
parent
6c6f721f35
commit
d1c905cda4
10
src/error.rs
10
src/error.rs
@ -21,7 +21,7 @@ pub enum Error {
|
|||||||
FileNotFound(PathBuf),
|
FileNotFound(PathBuf),
|
||||||
AlreadyExists,
|
AlreadyExists,
|
||||||
InvalidZipArchive(&'static str),
|
InvalidZipArchive(&'static str),
|
||||||
PermissionDenied,
|
PermissionDenied { error_title: String },
|
||||||
UnsupportedZipArchive(&'static str),
|
UnsupportedZipArchive(&'static str),
|
||||||
InternalError,
|
InternalError,
|
||||||
OofError(oof::OofError),
|
OofError(oof::OofError),
|
||||||
@ -156,7 +156,9 @@ impl fmt::Display for Error {
|
|||||||
Error::UnknownExtensionError(_) => todo!(),
|
Error::UnknownExtensionError(_) => todo!(),
|
||||||
Error::AlreadyExists => todo!(),
|
Error::AlreadyExists => todo!(),
|
||||||
Error::InvalidZipArchive(_) => 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::UnsupportedZipArchive(_) => todo!(),
|
||||||
Error::Custom { reason } => reason.clone(),
|
Error::Custom { reason } => reason.clone(),
|
||||||
};
|
};
|
||||||
@ -174,8 +176,8 @@ impl Error {
|
|||||||
impl From<std::io::Error> for Error {
|
impl From<std::io::Error> for Error {
|
||||||
fn from(err: std::io::Error) -> Self {
|
fn from(err: std::io::Error) -> Self {
|
||||||
match err.kind() {
|
match err.kind() {
|
||||||
std::io::ErrorKind::NotFound => panic!("{}", err),
|
std::io::ErrorKind::NotFound => todo!(),
|
||||||
std::io::ErrorKind::PermissionDenied => Self::PermissionDenied,
|
std::io::ErrorKind::PermissionDenied => Self::PermissionDenied { error_title: err.to_string() },
|
||||||
std::io::ErrorKind::AlreadyExists => Self::AlreadyExists,
|
std::io::ErrorKind::AlreadyExists => Self::AlreadyExists,
|
||||||
_other => Self::IoError { reason: err.to_string() },
|
_other => Self::IoError { reason: err.to_string() },
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user