Fix unsupported type message for some math related commands (#4672)

* Fix unsupported type message of some math related commands

* changing the error form for UnsupportedInput

* cargo fmt
This commit is contained in:
Justin Ma
2022-02-28 23:14:33 +08:00
committed by GitHub
parent 0924975b4c
commit b09acdb7f9
9 changed files with 54 additions and 15 deletions

View File

@@ -62,9 +62,12 @@ fn abs_helper(val: Value, head: Span) -> Value {
val: val.abs(),
span,
},
_ => Value::Error {
other => Value::Error {
error: ShellError::UnsupportedInput(
String::from("Only numerical values are supported"),
format!(
"Only numerical values are supported, input type: {:?}",
other.get_type()
),
head,
),
},

View File

@@ -53,7 +53,10 @@ fn operate(value: Value, head: Span) -> Value {
},
other => Value::Error {
error: ShellError::UnsupportedInput(
String::from("Only numerical values are supported"),
format!(
"Only numerical values are supported, input type: {:?}",
other.get_type()
),
other.span().unwrap_or(head),
),
},

View File

@@ -53,7 +53,10 @@ fn operate(value: Value, head: Span) -> Value {
},
other => Value::Error {
error: ShellError::UnsupportedInput(
String::from("Only numerical values are supported"),
format!(
"Only numerical values are supported, input type: {:?}",
other.get_type()
),
other.span().unwrap_or(head),
),
},

View File

@@ -94,7 +94,10 @@ fn operate(value: Value, head: Span, precision: Option<i64>) -> Value {
Value::Int { .. } => value,
other => Value::Error {
error: ShellError::UnsupportedInput(
String::from("Only numerical values are supported"),
format!(
"Only numerical values are supported, input type: {:?}",
other.get_type()
),
other.span().unwrap_or(head),
),
},

View File

@@ -62,7 +62,10 @@ fn operate(value: Value, head: Span) -> Value {
}
other => Value::Error {
error: ShellError::UnsupportedInput(
String::from("Only numerical values are supported"),
format!(
"Only numerical values are supported, input type: {:?}",
other.get_type()
),
other.span().unwrap_or(head),
),
},