mirror of
https://github.com/nushell/nushell.git
synced 2025-07-01 07:00:37 +02:00
Convert FileNotFound to named fields (#11120)
# Description Part of #10700 # User-Facing Changes None # Tests + Formatting - 🟢 `toolkit fmt` - 🟢 `toolkit clippy` - 🟢 `toolkit test` - 🟢 `toolkit test stdlib` # After Submitting N/A
This commit is contained in:
4
crates/nu-command/src/env/source_env.rs
vendored
4
crates/nu-command/src/env/source_env.rs
vendored
@ -55,7 +55,9 @@ impl Command for SourceEnv {
|
||||
)? {
|
||||
PathBuf::from(&path)
|
||||
} else {
|
||||
return Err(ShellError::FileNotFound(source_filename.span));
|
||||
return Err(ShellError::FileNotFound {
|
||||
span: source_filename.span,
|
||||
});
|
||||
};
|
||||
|
||||
if let Some(parent) = file_path.parent() {
|
||||
|
@ -111,7 +111,7 @@ impl Command for Cp {
|
||||
};
|
||||
|
||||
if sources.is_empty() {
|
||||
return Err(ShellError::FileNotFound(src.span));
|
||||
return Err(ShellError::FileNotFound { span: src.span });
|
||||
}
|
||||
|
||||
if sources.len() > 1 && !destination.is_dir() {
|
||||
|
@ -80,7 +80,9 @@ impl Command for Mv {
|
||||
arg_glob(&spanned_source, &path).map_or_else(|_| Vec::new(), Iterator::collect);
|
||||
|
||||
if sources.is_empty() {
|
||||
return Err(ShellError::FileNotFound(spanned_source.span));
|
||||
return Err(ShellError::FileNotFound {
|
||||
span: spanned_source.span,
|
||||
});
|
||||
}
|
||||
|
||||
// We have two possibilities.
|
||||
|
@ -105,7 +105,7 @@ 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 { span },
|
||||
_ => err,
|
||||
})?
|
||||
.1
|
||||
|
@ -173,7 +173,7 @@ impl Command for UCp {
|
||||
for p in paths {
|
||||
let exp_files = arg_glob(&p, &cwd)?.collect::<Vec<GlobResult>>();
|
||||
if exp_files.is_empty() {
|
||||
return Err(ShellError::FileNotFound(p.span));
|
||||
return Err(ShellError::FileNotFound { span: p.span });
|
||||
};
|
||||
let mut app_vals: Vec<PathBuf> = Vec::new();
|
||||
for v in exp_files {
|
||||
|
@ -117,7 +117,9 @@ impl Command for NuCheck {
|
||||
if let Some(path) = path {
|
||||
path
|
||||
} else {
|
||||
return Err(ShellError::FileNotFound(path_str.span));
|
||||
return Err(ShellError::FileNotFound {
|
||||
span: path_str.span,
|
||||
});
|
||||
}
|
||||
}
|
||||
Err(error) => return Err(error),
|
||||
|
Reference in New Issue
Block a user