Convert ShellError::UnsupportedInput to named fields (#10971)

# Description

This is easy to do with rust-analyzer, but I didn't want to just pump
these all out without feedback.

Part of #10700

# User-Facing Changes

None

# Tests + Formatting

- 🟢 `toolkit fmt`
- 🟢 `toolkit clippy`
- 🟢 `toolkit test`
- 🟢 `toolkit test stdlib`

# After Submitting

N/A

---------

Co-authored-by: Stefan Holderbach <sholderbach@users.noreply.github.com>
This commit is contained in:
Eric Hodel
2023-11-07 14:25:32 -08:00
committed by GitHub
parent 45b02ce2ab
commit 7a3cbf43e8
56 changed files with 506 additions and 567 deletions

View File

@ -180,12 +180,12 @@ fn run(call: &Call, args: &Arguments, input: PipelineData) -> Result<PipelineDat
metadata,
)),
PipelineData::Empty { .. } => Err(ShellError::PipelineEmpty { dst_span: head }),
_ => Err(ShellError::UnsupportedInput(
"Input value cannot be joined".to_string(),
"value originates from here".into(),
head,
input.span().unwrap_or(call.head),
)),
_ => Err(ShellError::UnsupportedInput {
msg: "Input value cannot be joined".to_string(),
input: "value originates from here".into(),
msg_span: head,
input_span: input.span().unwrap_or(call.head),
}),
}
}
@ -249,14 +249,9 @@ fn merge_record(record: &Record, head: Span, span: Span) -> Result<PathBuf, Shel
for key in &record.cols {
if !super::ALLOWED_COLUMNS.contains(&key.as_str()) {
let allowed_cols = super::ALLOWED_COLUMNS.join(", ");
return Err(ShellError::UnsupportedInput(
format!(
return Err(ShellError::UnsupportedInput { msg: format!(
"Column '{key}' is not valid for a structured path. Allowed columns on this platform are: {allowed_cols}"
),
"value originates from here".into(),
head,
span
));
), input: "value originates from here".into(), msg_span: head, input_span: span });
}
}