summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJo-Philipp Wich <jo@mein.io>2020-10-14 13:49:32 +0200
committerJo-Philipp Wich <jo@mein.io>2020-10-14 13:50:19 +0200
commitce01a7fdc8d49977e3d46dab0615580f90c6525c (patch)
treeee96c6e0e41770818a9afb7c3a28dcc5136a029d
parenta71ebe62e75db9402d89c6af1ab69051440bf892 (diff)
eval: forward exceptions in `if` conditions
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
-rw-r--r--eval.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/eval.c b/eval.c
index af3a518..2dbb4c8 100644
--- a/eval.c
+++ b/eval.c
@@ -454,8 +454,11 @@ ut_execute_if(struct ut_state *state, uint32_t off)
uint32_t cond = op ? op->tree.operand[0] : 0;
uint32_t Then = op ? op->tree.operand[1] : 0;
uint32_t Else = op ? op->tree.operand[2] : 0;
+ bool res = ut_test_condition(state, cond);
- if (ut_test_condition(state, cond))
+ if (state->exception)
+ return json_object_get(state->exception);
+ else if (res)
return ut_execute_op_sequence(state, Then);
else if (Else)
return ut_execute_op_sequence(state, Else);