Properly implement percentage() error messages
This commit is contained in:
parent
af5c945dfa
commit
908104ec1c
@ -9,7 +9,8 @@ pub(crate) fn register(f: &mut BTreeMap<String, Builtin>) {
|
|||||||
max_args!(args, 1);
|
max_args!(args, 1);
|
||||||
let num = match arg!(args, 0, "number").eval() {
|
let num = match arg!(args, 0, "number").eval() {
|
||||||
Value::Dimension(n, Unit::None) => n * Number::from(100),
|
Value::Dimension(n, Unit::None) => n * Number::from(100),
|
||||||
_ => todo!("expected unitless number in builtin function `percentage()`")
|
v @ Value::Dimension(..) => return Err(format!("$number: Expected {} to have no units.", v).into()),
|
||||||
|
v => return Err(format!("$number: {} is not a number.", v).into()),
|
||||||
};
|
};
|
||||||
Ok(Value::Dimension(num, Unit::Percent))
|
Ok(Value::Dimension(num, Unit::Percent))
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user