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

@ -73,12 +73,12 @@ impl Command for Input {
});
if numchar.item < 1 {
return Err(ShellError::UnsupportedInput(
"Number of characters to read has to be positive".to_string(),
"value originated from here".to_string(),
call.head,
numchar.span,
));
return Err(ShellError::UnsupportedInput {
msg: "Number of characters to read has to be positive".to_string(),
input: "value originated from here".to_string(),
msg_span: call.head,
input_span: numchar.span,
});
}
if let Some(prompt) = &prompt {

View File

@ -178,21 +178,21 @@ impl EventTypeFilter {
}
fn wrong_type_error(head: Span, val: &str, val_span: Span) -> ShellError {
ShellError::UnsupportedInput(
format!("{} is not a valid event type", val),
"value originates from here".into(),
head,
val_span,
)
ShellError::UnsupportedInput {
msg: format!("{} is not a valid event type", val),
input: "value originates from here".into(),
msg_span: head,
input_span: val_span,
}
}
fn bad_list_error(head: Span, value: &Value) -> ShellError {
ShellError::UnsupportedInput(
"--types expects a list of strings".to_string(),
"value originates from here".into(),
head,
value.span(),
)
ShellError::UnsupportedInput {
msg: "--types expects a list of strings".to_string(),
input: "value originates from here".into(),
msg_span: head,
input_span: value.span(),
}
}
/// Enable capturing of all events allowed by this filter.