From 8b55757a0b82fa4fba81feaf70eb0f6e97aaab9c Mon Sep 17 00:00:00 2001 From: Darren Schroeder <343840+fdncred@users.noreply.github.com> Date: Sun, 7 Aug 2022 15:25:05 -0500 Subject: [PATCH] add more verbose error messages to mv (#6259) * add more verbose error messages to mv * tweak output * clippy * yet another tweak --- crates/nu-command/src/filesystem/mv.rs | 31 ++++++++++++++++++++------ 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/crates/nu-command/src/filesystem/mv.rs b/crates/nu-command/src/filesystem/mv.rs index 743d54f279..c31db01f9e 100644 --- a/crates/nu-command/src/filesystem/mv.rs +++ b/crates/nu-command/src/filesystem/mv.rs @@ -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(), + )) + } } }) }