mirror of
https://github.com/nushell/nushell.git
synced 2025-08-09 22:07:57 +02:00
Improve external output in subexprs (#294)
This commit is contained in:
@ -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)),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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,
|
||||
)),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
@ -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),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user