mirror of
https://github.com/nushell/nushell.git
synced 2025-08-10 07:18:19 +02:00
Replace some PipelineMismatch by OnlySupportsThisInputType by shell error (#15447)
sub-issue of #10698 according to @sholderbach (Description largely edited, since the scope of the PR changed) # Description Context: `ShellError::OnlySupportsThisInputType` was a duplicate of `ShellError::PipelineMismatch` so I - replaced some occurences of PipelineMismatch by OnlySupportsThisInputType For another PR - replace the remaining occurences - removed OnlySupportsThisInputType from nu-protocol # User-Facing Changes The error message will be different -> but consistent # Tests + Formatting OK # After Submitting Nothing required
This commit is contained in:
@ -181,11 +181,14 @@ fn operate(
|
||||
Value::List { vals, .. } => {
|
||||
let iter = vals.into_iter().map(move |val| {
|
||||
let span = val.span();
|
||||
val.into_string().map_err(|_| ShellError::PipelineMismatch {
|
||||
exp_input_type: "string".into(),
|
||||
dst_span: head,
|
||||
src_span: span,
|
||||
})
|
||||
let type_ = val.get_type();
|
||||
val.into_string()
|
||||
.map_err(|_| ShellError::OnlySupportsThisInputType {
|
||||
exp_input_type: "string".into(),
|
||||
wrong_type: type_.to_string(),
|
||||
dst_span: head,
|
||||
src_span: span,
|
||||
})
|
||||
});
|
||||
|
||||
let iter = ParseIter {
|
||||
@ -199,8 +202,9 @@ fn operate(
|
||||
|
||||
Ok(ListStream::new(iter, head, Signals::empty()).into())
|
||||
}
|
||||
value => Err(ShellError::PipelineMismatch {
|
||||
value => Err(ShellError::OnlySupportsThisInputType {
|
||||
exp_input_type: "string".into(),
|
||||
wrong_type: value.get_type().to_string(),
|
||||
dst_span: head,
|
||||
src_span: value.span(),
|
||||
}),
|
||||
|
@ -153,8 +153,9 @@ fn split_chars_helper(v: &Value, name: Span, graphemes: bool) -> Value {
|
||||
)
|
||||
} else {
|
||||
Value::error(
|
||||
ShellError::PipelineMismatch {
|
||||
ShellError::OnlySupportsThisInputType {
|
||||
exp_input_type: "string".into(),
|
||||
wrong_type: v.get_type().to_string(),
|
||||
dst_span: name,
|
||||
src_span: v_span,
|
||||
},
|
||||
|
@ -255,8 +255,9 @@ fn split_column_helper(
|
||||
v => {
|
||||
let span = v.span();
|
||||
vec![Value::error(
|
||||
ShellError::PipelineMismatch {
|
||||
ShellError::OnlySupportsThisInputType {
|
||||
exp_input_type: "string".into(),
|
||||
wrong_type: v.get_type().to_string(),
|
||||
dst_span: head,
|
||||
src_span: span,
|
||||
},
|
||||
|
@ -219,8 +219,9 @@ fn split_row_helper(v: &Value, regex: &Regex, max_split: Option<usize>, name: Sp
|
||||
}
|
||||
} else {
|
||||
vec![Value::error(
|
||||
ShellError::PipelineMismatch {
|
||||
ShellError::OnlySupportsThisInputType {
|
||||
exp_input_type: "string".into(),
|
||||
wrong_type: v.get_type().to_string(),
|
||||
dst_span: name,
|
||||
src_span: v_span,
|
||||
},
|
||||
|
@ -226,8 +226,9 @@ fn split_words_helper(v: &Value, word_length: Option<usize>, span: Span, graphem
|
||||
Value::list(words, v_span)
|
||||
} else {
|
||||
Value::error(
|
||||
ShellError::PipelineMismatch {
|
||||
ShellError::OnlySupportsThisInputType {
|
||||
exp_input_type: "string".into(),
|
||||
wrong_type: v.get_type().to_string(),
|
||||
dst_span: span,
|
||||
src_span: v_span,
|
||||
},
|
||||
|
@ -237,14 +237,16 @@ fn run(
|
||||
input.map(
|
||||
move |v| {
|
||||
let value_span = v.span();
|
||||
let type_ = v.get_type();
|
||||
match v.coerce_into_string() {
|
||||
Ok(s) => {
|
||||
let contents = if is_path { s.replace('\\', "\\\\") } else { s };
|
||||
str_expand(&contents, span, value_span)
|
||||
}
|
||||
Err(_) => Value::error(
|
||||
ShellError::PipelineMismatch {
|
||||
ShellError::OnlySupportsThisInputType {
|
||||
exp_input_type: "string".into(),
|
||||
wrong_type: type_.to_string(),
|
||||
dst_span: span,
|
||||
src_span: value_span,
|
||||
},
|
||||
|
@ -108,6 +108,7 @@ fn stats(
|
||||
input.map(
|
||||
move |v| {
|
||||
let value_span = v.span();
|
||||
let type_ = v.get_type();
|
||||
// First, obtain the span. If this fails, propagate the error that results.
|
||||
if let Value::Error { error, .. } = v {
|
||||
return Value::error(*error, span);
|
||||
@ -116,8 +117,9 @@ fn stats(
|
||||
match v.coerce_into_string() {
|
||||
Ok(s) => counter(&s, span),
|
||||
Err(_) => Value::error(
|
||||
ShellError::PipelineMismatch {
|
||||
ShellError::OnlySupportsThisInputType {
|
||||
exp_input_type: "string".into(),
|
||||
wrong_type: type_.to_string(),
|
||||
dst_span: span,
|
||||
src_span: value_span,
|
||||
},
|
||||
|
Reference in New Issue
Block a user