Include argument name in bounds error
This commit is contained in:
parent
5f59c71752
commit
24dc99affe
@ -88,7 +88,7 @@ pub(crate) fn register(f: &mut BTreeMap<String, Builtin>) {
|
|||||||
v => return Err(format!("$color: {} is not a color.", v).into()),
|
v => return Err(format!("$color: {} is not a color.", v).into()),
|
||||||
};
|
};
|
||||||
let amount = match arg!(args, 1, "amount").eval() {
|
let amount = match arg!(args, 1, "amount").eval() {
|
||||||
Value::Dimension(n, u) => bound!(n, u, 0, 100) / Number::from(100),
|
Value::Dimension(n, u) => bound!("amount", n, u, 0, 100) / Number::from(100),
|
||||||
v => return Err(format!("$amount: {} is not a number.", v).into())
|
v => return Err(format!("$amount: {} is not a number.", v).into())
|
||||||
};
|
};
|
||||||
Ok(Value::Color(color.lighten(amount)))
|
Ok(Value::Color(color.lighten(amount)))
|
||||||
|
@ -48,11 +48,11 @@ macro_rules! max_args {
|
|||||||
}
|
}
|
||||||
|
|
||||||
macro_rules! bound {
|
macro_rules! bound {
|
||||||
($arg:ident, $unit:ident, $low:literal, $high:literal) => {
|
($name:literal, $arg:ident, $unit:ident, $low:literal, $high:literal) => {
|
||||||
if $arg > Number::from($high) || $arg < Number::from($low) {
|
if $arg > Number::from($high) || $arg < Number::from($low) {
|
||||||
return Err(format!(
|
return Err(format!(
|
||||||
"Expected {}{} to be within {}{} and {}{}.",
|
"${}: Expected {}{} to be within {}{} and {}{}.",
|
||||||
$arg, $unit, $low, $unit, $high, $unit,
|
$name, $arg, $unit, $low, $unit, $high, $unit,
|
||||||
)
|
)
|
||||||
.into());
|
.into());
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user