mirror of
https://github.com/nushell/nushell.git
synced 2025-08-10 01:07:48 +02:00
Refactor: Construct IoError
from std::io::Error
instead of std::io::ErrorKind
(#15777)
This commit is contained in:
@ -4,7 +4,7 @@ use nu_protocol::{
|
||||
ShellError, Span, Type, Value, VarId,
|
||||
ast::Expr,
|
||||
engine::{Call, EngineState, Stack, StateWorkingSet},
|
||||
shell_error::io::{ErrorKindExt, IoError, NotFound},
|
||||
shell_error::io::{IoError, IoErrorExt, NotFound},
|
||||
};
|
||||
use std::{
|
||||
collections::HashMap,
|
||||
@ -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().not_found_as(NotFound::Directory),
|
||||
err.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().not_found_as(NotFound::Directory),
|
||||
err.not_found_as(NotFound::Directory),
|
||||
"Could not canonicalize current dir",
|
||||
nu_protocol::location!(),
|
||||
PathBuf::from(cwd),
|
||||
|
@ -1529,7 +1529,7 @@ fn open_file(ctx: &EvalContext<'_>, path: &Value, append: bool) -> Result<Arc<Fi
|
||||
let file = options
|
||||
.create(true)
|
||||
.open(&path_expanded)
|
||||
.map_err(|err| IoError::new(err.kind(), path.span(), path_expanded))?;
|
||||
.map_err(|err| IoError::new(err, path.span(), path_expanded))?;
|
||||
Ok(Arc::new(file))
|
||||
}
|
||||
|
||||
|
@ -81,7 +81,7 @@ pub fn glob_from(
|
||||
}
|
||||
Ok(p) => p,
|
||||
Err(err) => {
|
||||
return Err(IoError::new(err.kind(), pattern_span, path).into());
|
||||
return Err(IoError::new(err, pattern_span, path).into());
|
||||
}
|
||||
};
|
||||
(path.parent().map(|parent| parent.to_path_buf()), path)
|
||||
|
Reference in New Issue
Block a user