mirror of
https://github.com/nushell/nushell
synced 2024-12-28 14:03:09 +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)
|
fs_extra::dir::move_dir(from, to, &options)
|
||||||
} {
|
} {
|
||||||
Ok(_) => Ok(()),
|
Ok(_) => Ok(()),
|
||||||
Err(e) => Err(ShellError::GenericError(
|
Err(e) => {
|
||||||
format!("Could not move {:?} to {:?}. {:}", from, to, 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(),
|
"could not move".into(),
|
||||||
Some(from_span),
|
Some(from_span),
|
||||||
None,
|
None,
|
||||||
Vec::new(),
|
Vec::new(),
|
||||||
)),
|
))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue