mirror of
https://github.com/nushell/nushell.git
synced 2025-08-09 20:57:49 +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:
@ -3,7 +3,7 @@ pub use nu_protocol::{
|
||||
ast::CellPath,
|
||||
engine::{Call, Command, EngineState, Stack, StateWorkingSet},
|
||||
record,
|
||||
shell_error::io::IoError,
|
||||
shell_error::io::*,
|
||||
ByteStream, ByteStreamType, Category, ErrSpan, Example, IntoInterruptiblePipelineData,
|
||||
IntoPipelineData, IntoSpanned, IntoValue, PipelineData, Record, ShellError, Signature, Span,
|
||||
Spanned, SyntaxShape, Type, Value,
|
||||
|
@ -3,7 +3,7 @@ use nu_path::canonicalize_with;
|
||||
use nu_protocol::{
|
||||
ast::Expr,
|
||||
engine::{Call, EngineState, Stack, StateWorkingSet},
|
||||
shell_error::io::IoError,
|
||||
shell_error::io::{ErrorKindExt, IoError, NotFound},
|
||||
ShellError, Span, Type, Value, VarId,
|
||||
};
|
||||
use std::{
|
||||
@ -221,7 +221,7 @@ pub fn current_dir(engine_state: &EngineState, stack: &Stack) -> Result<PathBuf,
|
||||
// be an absolute path already.
|
||||
canonicalize_with(&cwd, ".").map_err(|err| {
|
||||
ShellError::Io(IoError::new_internal_with_path(
|
||||
err.kind(),
|
||||
err.kind().not_found_as(NotFound::Directory),
|
||||
"Could not canonicalize current dir",
|
||||
nu_protocol::location!(),
|
||||
PathBuf::from(cwd),
|
||||
@ -241,7 +241,7 @@ pub fn current_dir_const(working_set: &StateWorkingSet) -> Result<PathBuf, Shell
|
||||
// be an absolute path already.
|
||||
canonicalize_with(&cwd, ".").map_err(|err| {
|
||||
ShellError::Io(IoError::new_internal_with_path(
|
||||
err.kind(),
|
||||
err.kind().not_found_as(NotFound::Directory),
|
||||
"Could not canonicalize current dir",
|
||||
nu_protocol::location!(),
|
||||
PathBuf::from(cwd),
|
||||
|
Reference in New Issue
Block a user