Convert Shellerror::GenericError to named fields (#11230)

# Description

Replace `.to_string()` used in `GenericError` with `.into()` as
`.into()` seems more popular

Replace `Vec::new()` used in `GenericError` with `vec![]` as `vec![]`
seems more popular

(There are so, so many)
This commit is contained in:
Eric Hodel
2023-12-06 15:40:03 -08:00
committed by GitHub
parent b03f1efac4
commit a95a4505ef
160 changed files with 2975 additions and 3228 deletions

View File

@ -68,13 +68,13 @@ impl Command for ConfigEnv {
let nu_config = match engine_state.get_config_path("env-path") {
Some(path) => path.clone(),
None => {
return Err(ShellError::GenericError(
"Could not find $nu.env-path".to_string(),
"Could not find $nu.env-path".to_string(),
None,
None,
Vec::new(),
));
return Err(ShellError::GenericError {
error: "Could not find $nu.env-path".into(),
msg: "Could not find $nu.env-path".into(),
span: None,
help: None,
inner: vec![],
});
}
};

View File

@ -72,13 +72,13 @@ impl Command for ConfigNu {
let nu_config = match engine_state.get_config_path("config-path") {
Some(path) => path.clone(),
None => {
return Err(ShellError::GenericError(
"Could not find $nu.config-path".to_string(),
"Could not find $nu.config-path".to_string(),
None,
None,
Vec::new(),
));
return Err(ShellError::GenericError {
error: "Could not find $nu.config-path".into(),
msg: "Could not find $nu.config-path".into(),
span: None,
help: None,
inner: vec![],
});
}
};

View File

@ -51,13 +51,13 @@ impl Command for ConfigReset {
let mut config_path = match nu_path::config_dir() {
Some(path) => path,
None => {
return Err(ShellError::GenericError(
"Could not find config path".to_string(),
"Could not find config path".to_string(),
None,
None,
Vec::new(),
));
return Err(ShellError::GenericError {
error: "Could not find config path".into(),
msg: "Could not find config path".into(),
span: None,
help: None,
inner: vec![],
});
}
};
config_path.push("nushell");