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

@ -36,12 +36,12 @@ pub fn from_ics_call(call: &EvaluatedCall, input: &Value) -> Result<Value, Label
match calendar {
Ok(c) => output.push(calendar_to_value(c, head)),
Err(e) => output.push(Value::error(
ShellError::UnsupportedInput(
format!("input cannot be parsed as .ics ({e})"),
"value originates from here".into(),
head,
span,
),
ShellError::UnsupportedInput {
msg: format!("input cannot be parsed as .ics ({e})"),
input: "value originates from here".into(),
msg_span: head,
input_span: span,
},
span,
)),
}

View File

@ -40,12 +40,12 @@ pub fn from_ini_call(call: &EvaluatedCall, input: &Value) -> Result<Value, Label
// all sections with all its key value pairs
Ok(Value::record(sections, span))
}
Err(err) => Err(ShellError::UnsupportedInput(
format!("Could not load ini: {err}"),
"value originates from here".into(),
head,
span,
)
Err(err) => Err(ShellError::UnsupportedInput {
msg: format!("Could not load ini: {err}"),
input: "value originates from here".into(),
msg_span: head,
input_span: span,
}
.into()),
}
}

View File

@ -32,12 +32,12 @@ pub fn from_vcf_call(call: &EvaluatedCall, input: &Value) -> Result<Value, Label
let iter = parser.map(move |contact| match contact {
Ok(c) => contact_to_value(c, head),
Err(e) => Value::error(
ShellError::UnsupportedInput(
format!("input cannot be parsed as .vcf ({e})"),
"value originates from here".into(),
head,
span,
),
ShellError::UnsupportedInput {
msg: format!("input cannot be parsed as .vcf ({e})"),
input: "value originates from here".into(),
msg_span: head,
input_span: span,
},
span,
),
});