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

@@ -85,13 +85,13 @@ fn action(input: &Value, _arg: &CellPathOnlyArgs, head: Span) -> Value {
match val {
Ok(val) => Value::string(val, head),
Err(e) => Value::error(
ShellError::GenericError(
"Failed to decode string".into(),
e.to_string(),
Some(input_span),
None,
Vec::new(),
),
ShellError::GenericError {
error: "Failed to decode string".into(),
msg: e.to_string(),
span: Some(input_span),
help: None,
inner: vec![],
},
head,
),
}

View File

@@ -283,13 +283,13 @@ impl UrlComponents {
_ => {
nu_protocol::report_error_new(
engine_state,
&ShellError::GenericError(
format!("'{key}' is not a valid URL field"),
format!("remove '{key}' col from input record"),
Some(span),
None,
vec![],
),
&ShellError::GenericError {
error: format!("'{key}' is not a valid URL field"),
msg: format!("remove '{key}' col from input record"),
span: Some(span),
help: None,
inner: vec![],
},
);
Ok(self)
}