update miette and switch to GenericErrors (#5222)

This commit is contained in:
Kat Marchán
2022-04-18 05:34:10 -07:00
committed by GitHub
parent cf65f77b02
commit 1314a87cb0
141 changed files with 1569 additions and 689 deletions

View File

@ -60,13 +60,15 @@ documentation link at https://docs.rs/encoding_rs/0.8.28/encoding_rs/#statics"#
let bytes: Vec<u8> = stream.into_bytes()?.item;
let encoding = match Encoding::for_label(encoding.item.as_bytes()) {
None => Err(ShellError::SpannedLabeledError(
None => Err(ShellError::GenericError(
format!(
r#"{} is not a valid encoding, refer to https://docs.rs/encoding_rs/0.8.23/encoding_rs/#statics for a valid list of encodings"#,
encoding.item
),
"invalid encoding".into(),
encoding.span,
Some(encoding.span),
None,
Vec::new(),
)),
Some(encoding) => Ok(encoding),
}?;
@ -81,13 +83,15 @@ documentation link at https://docs.rs/encoding_rs/0.8.28/encoding_rs/#statics"#
}
PipelineData::Value(Value::Binary { val: bytes, .. }, ..) => {
let encoding = match Encoding::for_label(encoding.item.as_bytes()) {
None => Err(ShellError::SpannedLabeledError(
None => Err(ShellError::GenericError(
format!(
r#"{} is not a valid encoding, refer to https://docs.rs/encoding_rs/0.8.23/encoding_rs/#statics for a valid list of encodings"#,
encoding.item
),
"invalid encoding".into(),
encoding.span,
Some(encoding.span),
None,
Vec::new(),
)),
Some(encoding) => Ok(encoding),
}?;

View File

@ -149,10 +149,12 @@ where
let to_trim = match options.character.as_ref() {
Some(v) => {
if v.item.chars().count() > 1 {
return Err(ShellError::SpannedLabeledError(
return Err(ShellError::GenericError(
"Trim only works with single character".into(),
"needs single character".into(),
v.span,
Some(v.span),
None,
Vec::new(),
));
}
v.item.chars().next()