output: somewhat better error handling in cond and either
Some checks are pending
/ build (push) Waiting to run

This commit is contained in:
🪞👃🪞 2025-05-18 18:32:07 +03:00
parent 7ddbace030
commit 3bc739328e

View file

@ -25,9 +25,9 @@ try_from_expr!(<'source, 'state, E>: When<RenderBox<'state, E>>: |state, iter| {
let content = iter.next().expect("no content specified").value;
return Some(Self(
state.get(&mut iter)
.expect("no condition provided"),
.unwrap_or_else(||panic!("cond: no condition: {iter:?}")),
state.get_content(&content)
.unwrap_or_else(||panic!("no content corresponding to for {:?}", &content))
.unwrap_or_else(||panic!("cond: no content for {:?}: {iter:?}", &content))
))
}
});
@ -35,14 +35,16 @@ try_from_expr!(<'source, 'state, E>: When<RenderBox<'state, E>>: |state, iter| {
#[cfg(feature = "dsl")]
try_from_expr!(<'source, 'state, E>: Either<RenderBox<'state, E>, RenderBox<'state, E>>: |state, iter| {
if let Some(Token { value: Value::Key("either"), .. }) = iter.peek() {
let base = iter.clone();
let _ = iter.next().unwrap();
//panic!("{iter:?}");
return Some(Self(
state.get(&mut iter).expect("no condition provided"),
state.get(&mut iter)
.unwrap_or_else(||panic!("either: no condition: {base:?}")),
state.get_content(&iter.next().expect("no content specified").value)
.unwrap_or_else(||panic!("no content 1: {iter:?}")),
.unwrap_or_else(||panic!("either: no content 1: {base:?}")),
state.get_content(&iter.next().expect("no alternate specified").value)
.unwrap_or_else(||panic!("no content 2: {iter:?}")),
.unwrap_or_else(||panic!("either: no content 2: {base:?}")),
))
}
});