mirror of
https://github.com/nushell/nushell.git
synced 2025-08-14 14:38:57 +02:00
Specify which file not found in error (#11868)
# Description Currently, `ShellError::FileNotFound` shows the span where the error occurred but doesn't say which file wasn't found. This PR makes it so the help includes that (like the `DirectoryNotFound` error). # User-Facing Changes No breaking changes, it's just that when a file can't be found, the help will say which file couldn't be found: 
This commit is contained in:
@ -81,6 +81,7 @@ impl Command for Mv {
|
||||
|
||||
if sources.is_empty() {
|
||||
return Err(ShellError::FileNotFound {
|
||||
file: spanned_source.item.to_string(),
|
||||
span: spanned_source.span,
|
||||
});
|
||||
}
|
||||
|
@ -92,7 +92,10 @@ impl Command for Open {
|
||||
|
||||
for path in nu_engine::glob_from(&path, &cwd, call_span, None)
|
||||
.map_err(|err| match err {
|
||||
ShellError::DirectoryNotFound { span, .. } => ShellError::FileNotFound { span },
|
||||
ShellError::DirectoryNotFound { span, .. } => ShellError::FileNotFound {
|
||||
file: path.item.to_string(),
|
||||
span,
|
||||
},
|
||||
_ => err,
|
||||
})?
|
||||
.1
|
||||
|
@ -205,7 +205,10 @@ impl Command for UCp {
|
||||
.map(|f| f.1)?
|
||||
.collect();
|
||||
if exp_files.is_empty() {
|
||||
return Err(ShellError::FileNotFound { span: p.span });
|
||||
return Err(ShellError::FileNotFound {
|
||||
file: p.item.to_string(),
|
||||
span: p.span,
|
||||
});
|
||||
};
|
||||
let mut app_vals: Vec<PathBuf> = Vec::new();
|
||||
for v in exp_files {
|
||||
|
@ -121,7 +121,10 @@ impl Command for UMv {
|
||||
.map(|f| f.1)?
|
||||
.collect();
|
||||
if exp_files.is_empty() {
|
||||
return Err(ShellError::FileNotFound { span: p.span });
|
||||
return Err(ShellError::FileNotFound {
|
||||
file: p.item.to_string(),
|
||||
span: p.span,
|
||||
});
|
||||
};
|
||||
let mut app_vals: Vec<PathBuf> = Vec::new();
|
||||
for v in exp_files {
|
||||
|
Reference in New Issue
Block a user