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

@@ -102,12 +102,12 @@ impl HashableValue {
// Explicitly propagate errors instead of dropping them.
Value::Error { error, .. } => Err(*error),
_ => Err(ShellError::UnsupportedInput(
"input value is not hashable".into(),
format!("input type: {:?}", value.get_type()),
span,
value.span(),
)),
_ => Err(ShellError::UnsupportedInput {
msg: "input value is not hashable".into(),
input: format!("input type: {:?}", value.get_type()),
msg_span: span,
input_span: value.span(),
}),
}
}

View File

@@ -162,14 +162,9 @@ fn run_histogram(
let t = v.get_type();
let span = v.span();
inputs.push(HashableValue::from_value(v, head_span).map_err(|_| {
ShellError::UnsupportedInput(
"Since --column-name was not provided, only lists of hashable values are supported.".to_string(),
format!(
ShellError::UnsupportedInput { msg: "Since --column-name was not provided, only lists of hashable values are supported.".to_string(), input: format!(
"input type: {t:?}"
),
head_span,
span,
)
), msg_span: head_span, input_span: span }
})?)
}
}