mirror of
https://codeberg.org/unspeaker/tengri.git
synced 2025-12-06 11:46:42 +01:00
output: somewhat better error handling in cond and either
Some checks are pending
/ build (push) Waiting to run
Some checks are pending
/ build (push) Waiting to run
This commit is contained in:
parent
7ddbace030
commit
3bc739328e
1 changed files with 7 additions and 5 deletions
|
|
@ -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;
|
let content = iter.next().expect("no content specified").value;
|
||||||
return Some(Self(
|
return Some(Self(
|
||||||
state.get(&mut iter)
|
state.get(&mut iter)
|
||||||
.expect("no condition provided"),
|
.unwrap_or_else(||panic!("cond: no condition: {iter:?}")),
|
||||||
state.get_content(&content)
|
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")]
|
#[cfg(feature = "dsl")]
|
||||||
try_from_expr!(<'source, 'state, E>: Either<RenderBox<'state, E>, RenderBox<'state, E>>: |state, iter| {
|
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() {
|
if let Some(Token { value: Value::Key("either"), .. }) = iter.peek() {
|
||||||
|
let base = iter.clone();
|
||||||
let _ = iter.next().unwrap();
|
let _ = iter.next().unwrap();
|
||||||
//panic!("{iter:?}");
|
//panic!("{iter:?}");
|
||||||
return Some(Self(
|
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)
|
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)
|
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:?}")),
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue