return eval errors too

This commit is contained in:
Joeri Exelmans 2025-11-05 09:49:21 +01:00
parent 18c8b36151
commit 68b2cd924c
2 changed files with 11 additions and 9 deletions

Binary file not shown.

View file

@ -86,16 +86,18 @@ pub fn eval_boolean(s: &str, js_trace: JsValue) -> JsValue {
_ => return JsValue::from_str("expected boolean expression (this should never happen)"),
};
let mut result = Vec::<StateBuddyEvalResultEntry>::new();
if let Ok(r) = eval_result {
r.iter().for_each(|(timestamp, satisfied), | {
result.push(StateBuddyEvalResultEntry{
timestamp: timestamp.as_millis() as f64,
satisfied: *satisfied,
match eval_result {
Ok(r) => {
r.iter().for_each(|(timestamp, satisfied), | {
result.push(StateBuddyEvalResultEntry{
timestamp: timestamp.as_millis() as f64,
satisfied: *satisfied,
});
});
});
}
else {
return JsValue::from_str("failed to evaluate expression");
}
Err(e) => {
return JsValue::from_str(format!("failed to evaluate expression: {}", e).as_str());
}
}
to_value(&StateBuddyEvalResult { entries: result }).expect("fuuuck")
}