forked from extern/nushell
Convert more ShellError variants to named fields (#11173)
# Description Convert these ShellError variants to named fields: * CreateNotPossible * MoveNotPossibleSingle * DirectoryNotFoundCustom * DirectoryNotFound * NotADirectory * OutOfMemoryError * PermissionDeniedError * IOErrorSpanned * IOError * IOInterrupted Also place the `span` field of `DirectoryNotFound` last to match other errors. Part of #10700 (almost half done!) # User-Facing Changes None # Tests + Formatting - 🟢 `toolkit fmt` - 🟢 `toolkit clippy` - 🟢 `toolkit test` - 🟢 `toolkit test stdlib` # After Submitting N/A
This commit is contained in:
@@ -36,7 +36,10 @@ impl Command for Clear {
|
||||
CommandSys::new("cmd")
|
||||
.args(["/C", "cls"])
|
||||
.status()
|
||||
.map_err(|e| ShellError::IOErrorSpanned(e.to_string(), span))?;
|
||||
.map_err(|e| ShellError::IOErrorSpanned {
|
||||
msg: e.to_string(),
|
||||
span,
|
||||
})?;
|
||||
} else if cfg!(unix) {
|
||||
let mut cmd = CommandSys::new("/bin/sh");
|
||||
|
||||
@@ -46,7 +49,10 @@ impl Command for Clear {
|
||||
|
||||
cmd.args(["-c", "clear"])
|
||||
.status()
|
||||
.map_err(|e| ShellError::IOErrorSpanned(e.to_string(), span))?;
|
||||
.map_err(|e| ShellError::IOErrorSpanned {
|
||||
msg: e.to_string(),
|
||||
span,
|
||||
})?;
|
||||
}
|
||||
|
||||
Ok(Value::nothing(span).into_pipeline_data())
|
||||
|
@@ -110,7 +110,9 @@ impl Command for Input {
|
||||
{
|
||||
if k.modifiers == KeyModifiers::CONTROL && c == 'c' {
|
||||
crossterm::terminal::disable_raw_mode()?;
|
||||
return Err(ShellError::IOError("SIGINT".to_string()));
|
||||
return Err(ShellError::IOError {
|
||||
msg: "SIGINT".to_string(),
|
||||
});
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
@@ -196,7 +196,9 @@ impl Command for InputList {
|
||||
.items(&options)
|
||||
.report(false)
|
||||
.interact_on_opt(&Term::stderr())
|
||||
.map_err(|err| ShellError::IOError(format!("{}: {}", INTERACT_ERROR, err)))?,
|
||||
.map_err(|err| ShellError::IOError {
|
||||
msg: format!("{}: {}", INTERACT_ERROR, err),
|
||||
})?,
|
||||
)
|
||||
} else if call.has_flag("fuzzy") {
|
||||
let fuzzy_select = FuzzySelect::new(); //::with_theme(&theme);
|
||||
@@ -211,7 +213,9 @@ impl Command for InputList {
|
||||
.default(0)
|
||||
.report(false)
|
||||
.interact_on_opt(&Term::stderr())
|
||||
.map_err(|err| ShellError::IOError(format!("{}: {}", INTERACT_ERROR, err)))?,
|
||||
.map_err(|err| ShellError::IOError {
|
||||
msg: format!("{}: {}", INTERACT_ERROR, err),
|
||||
})?,
|
||||
)
|
||||
} else {
|
||||
let select = Select::new(); //::with_theme(&theme);
|
||||
@@ -225,7 +229,9 @@ impl Command for InputList {
|
||||
.default(0)
|
||||
.report(false)
|
||||
.interact_on_opt(&Term::stderr())
|
||||
.map_err(|err| ShellError::IOError(format!("{}: {}", INTERACT_ERROR, err)))?,
|
||||
.map_err(|err| ShellError::IOError {
|
||||
msg: format!("{}: {}", INTERACT_ERROR, err),
|
||||
})?,
|
||||
)
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user