mirror of
https://github.com/nushell/nushell.git
synced 2025-08-09 06:25:43 +02:00
More precise ErrorKind::NotFound
errors (#15149)
In this PR, the two new variants for `ErrorKind`, `FileNotFound` and `DirectoryNotFound` with a nice `not_found_as` method for the `ErrorKind` to easily specify the `NotFound` errors. I also updated some places where I could of think of with these new variants and the message for `NotFound` is no longer "Entity not found" but "Not found" to be less strange. closes #15142 closes #15055
This commit is contained in:
@ -88,7 +88,7 @@ impl Command for Cd {
|
||||
path
|
||||
} else {
|
||||
return Err(shell_error::io::IoError::new(
|
||||
std::io::ErrorKind::NotFound,
|
||||
ErrorKind::DirectoryNotFound,
|
||||
v.span,
|
||||
PathBuf::from(path_no_whitespace),
|
||||
)
|
||||
@ -98,7 +98,7 @@ impl Command for Cd {
|
||||
let path = nu_path::expand_path_with(path_no_whitespace, &cwd, true);
|
||||
if !path.exists() {
|
||||
return Err(shell_error::io::IoError::new(
|
||||
std::io::ErrorKind::NotFound,
|
||||
ErrorKind::DirectoryNotFound,
|
||||
v.span,
|
||||
PathBuf::from(path_no_whitespace),
|
||||
)
|
||||
|
@ -98,6 +98,7 @@ impl Command for Open {
|
||||
for path in nu_engine::glob_from(&path, &cwd, call_span, None)
|
||||
.map_err(|err| match err {
|
||||
ShellError::Io(mut err) => {
|
||||
err.kind = err.kind.not_found_as(NotFound::File);
|
||||
err.span = arg_span;
|
||||
err.into()
|
||||
}
|
||||
|
Reference in New Issue
Block a user