add more verbose error messages to mv (#6259)

* add more verbose error messages to mv

* tweak output

* clippy

* yet another tweak
This commit is contained in:
Darren Schroeder 2022-08-07 15:25:05 -05:00 committed by GitHub
parent 84fae6e07e
commit 8b55757a0b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -285,13 +285,30 @@ fn move_item(from: &Path, from_span: Span, to: &Path) -> Result<(), ShellError>
fs_extra::dir::move_dir(from, to, &options)
} {
Ok(_) => Ok(()),
Err(e) => Err(ShellError::GenericError(
format!("Could not move {:?} to {:?}. {:}", from, to, e),
"could not move".into(),
Some(from_span),
None,
Vec::new(),
)),
Err(e) => {
let error_kind = match e.kind {
fs_extra::error::ErrorKind::Io(io) => {
format!("I/O error: {}", io)
}
fs_extra::error::ErrorKind::StripPrefix(sp) => {
format!("Strip prefix error: {}", sp)
}
fs_extra::error::ErrorKind::OsString(os) => {
format!("OsString error: {:?}", os.to_str())
}
_ => e.to_string(),
};
Err(ShellError::GenericError(
format!(
"Could not move {:?} to {:?}. Error Kind: {}",
from, to, error_kind
),
"could not move".into(),
Some(from_span),
None,
Vec::new(),
))
}
}
})
}