Improve external output in subexprs (#294)

This commit is contained in:
JT
2021-11-06 18:50:33 +13:00
committed by GitHub
parent c7d159a0f3
commit 02b8027749
50 changed files with 320 additions and 136 deletions

View File

@ -131,7 +131,7 @@ pub fn action(input: &Value, span: Span) -> Value {
fn int_from_string(a_string: &str, span: Span) -> Result<i64, ShellError> {
match a_string.parse::<bytesize::ByteSize>() {
Ok(n) => Ok(n.0 as i64),
Err(_) => Err(ShellError::CantConvert("int".into(), span)),
Err(_) => Err(ShellError::CantConvert("int".into(), "string".into(), span)),
}
}

View File

@ -137,7 +137,11 @@ fn int_from_string(a_string: &str, span: Span) -> Result<i64, ShellError> {
Ok(n) => Ok(n),
Err(_) => match a_string.parse::<f64>() {
Ok(f) => Ok(f as i64),
_ => Err(ShellError::CantConvert("into int".into(), span)),
_ => Err(ShellError::CantConvert(
"into int".into(),
"string".into(),
span,
)),
},
}
}

View File

@ -229,11 +229,8 @@ pub fn action(
span,
),
},
_ => Value::Error {
error: ShellError::CantConvert(
String::from(" into string. Probably this type is not supported yet"),
span,
),
x => Value::Error {
error: ShellError::CantConvert(String::from("string"), x.get_type().to_string(), span),
},
}
}