mirror of
https://github.com/nushell/nushell
synced 2024-12-27 05:23:11 +00:00
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:
parent
84fae6e07e
commit
8b55757a0b
1 changed files with 24 additions and 7 deletions
|
@ -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(),
|
||||
))
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue