forked from extern/nushell
update miette and switch to GenericErrors (#5222)
This commit is contained in:
@ -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),
|
||||
}?;
|
||||
|
@ -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()
|
||||
|
Reference in New Issue
Block a user