flowon failureinvoice v1examples/invoice/invoice.flow · dandori doc
An order holds its goods until its payment is due, then ships them once paid, or puts them back
flowon failure| Line | Call | Calls | Retries | Timeout | When it fails | Case after |
|---|---|---|---|---|---|---|
| 59 | hold ← reserve(…) | book stock.reserve.hold, starts stock.reserve | — | — | out_of_stock → line 60timeout, failure → on failure | hold: held |
| 61 | due = terms.payment(…) | the date payment of payment_terms.cal | 2 times, after 1 second and 2 (failure, timeout) | 10 seconds | timeout, failure → on failure | — |
| 63 | payment = check_payment(…) | GET https://payments.example.com/orders/{order}/payment, idempotent | 2 times every 10 seconds (failure, timeout) | — | timeout, failure → on failure | — |
| 66 | hold ← ship(…) | book stock.reserve.post, sends post | — | — | expired → line 67timeout, failure → on failure | hold: posted |
| 70 | hold ← put_back(…) | book stock.reserve.void, sends void | — | — | expired → line 71already_posted, timeout, failure → on failure | hold: voided |
| 78 | hold ← put_back(…) | book stock.reserve.void, sends void | — | — | expired → line 79already_posted → line 80timeout, failure → line 81 | hold: voided |
| Line | End | hold |
|---|---|---|
| 60 | succeed outcome = out_of_stock, due = none | not started |
| 67 | succeed outcome = not_paid, due = due.day | expired |
| 68 | succeed outcome = shipped, due = due.day | posted |
| 72 | succeed outcome = not_paid, due = due.day | voided, expired |
| 81 | fail NotPutBack "the goods held for the order could not be put back" leaving hold | handed over as it is: held, posted, voided, expired |
| 81 | on failure runs to its end, and the workflow fails with the error that started it | not started, or posted, voided, expired |
Pick a step to see what the checker knows there. Pick a scenario on the left to light up the way its run goes; the number beside a step is how often the run passes it.
invoice v1An order holds its goods until its payment is due, then ships them once paid, or puts them back
order: Orderoutcome: Outcome, due: date?now range >=2026-01-01 <=2027-12-31examples/invoice/invoice.flowhold ← reserve(…) line 5959 hold <- reserve(order: order.id, sku: order.sku, qty: order.quantity) 60 on out_of_stock => succeed outcome = out_of_stock, due = none
hold: not startedbook stock.reserve.hold, starts stock.reserveout_of_stock → line 60timeout, failure → on failurehold: held32 # The book holds the goods for the order: chobo's client runs the hold, and a refusal comes back 33 # with the reason the book gives it. 34 task reserve(order: string, sku: string, qty: int) -> stock.reserve 35 book stock.reserve.hold 36 starts stock.reserve 37 errors out_of_stock
succeed outcome = out_of_stock, due = none line 60 60 on out_of_stock => succeed outcome = out_of_stock, due = none
hold: not startedhold: not starteddue = terms.payment(…) line 61 61 let due = terms.payment(received: now)
hold: heldpayment of payment_terms.caltimeout, failure → on failure10 use dates terms from "dates/payment_terms.cal" 11 lambda "arn:aws:lambda:eu-west-2:123456789012:function:payment-terms"
wait until due.at line 62 62 wait until due.at
hold: heldpayment = check_payment(…) line 63 63 let payment = check_payment(order: order.id, due: due.day)
hold: heldGET https://payments.example.com/orders/{order}/payment, idempotenttimeout, failure → on failure49 task check_payment(order: string, due: date) -> Payment 50 http GET "https://payments.example.com/orders/{order}/payment" 51 connection "arn:aws:events:eu-west-2:123456789012:connection/payments/1a2b3c" 52 retry 2 times every 10 seconds 53 idempotent
match payment.paid line 6464 match payment.paid 65 true => 69 false =>
hold: heldhold ← ship(…) line 6666 hold <- ship(order: order.id, sku: order.sku) 67 on expired => succeed outcome = not_paid, due = due.day
hold: heldbook stock.reserve.post, sends postexpired → line 67timeout, failure → on failurehold: posted39 task ship(order: string, sku: string) -> stock.reserve 40 book stock.reserve.post 41 sends post 42 errors expired
succeed outcome = not_paid, due = due.day line 67 67 on expired => succeed outcome = not_paid, due = due.day
hold: expiredhold: expiredsucceed outcome = shipped, due = due.day line 68 68 succeed outcome = shipped, due = due.day
hold: postedhold: postedhold ← put_back(…) line 7070 hold <- put_back(order: order.id, sku: order.sku) 71 on expired => pass
hold: heldbook stock.reserve.void, sends voidexpired → line 71already_posted, timeout, failure → on failurehold: voided44 task put_back(order: string, sku: string) -> stock.reserve 45 book stock.reserve.void 46 sends void 47 errors expired, already_posted
succeed outcome = not_paid, due = due.day line 72 72 succeed outcome = not_paid, due = due.day
hold: voided, expiredhold: voided, expiredend: succeedsThe flow runs to its end, and the workflow succeeds.
on failure line 74Runs when a call fails and nothing at the call handles the error. When it runs to its end, the workflow fails with that error. It comes here from the calls on lines 59, 61, 63, 66 and 70. It runs too when now on line 61 is outside the period the workflow runs in, >=2026-01-01 <=2027-12-31.
match hold.state line 7575 match hold.state 76 none => pass 77 held =>
hold: not started, or held, posted, voided, expiredhold ← put_back(…) line 7878 hold <- put_back(order: order.id, sku: order.sku) 79 on expired => pass 80 on already_posted => pass 81 on failure => fail NotPutBack "the goods held for the order could not be put back" leaving hold
hold: held, posted, voided, expiredbook stock.reserve.void, sends voidexpired → line 79already_posted → line 80timeout, failure → line 81hold: voided44 task put_back(order: string, sku: string) -> stock.reserve 45 book stock.reserve.void 46 sends void 47 errors expired, already_posted
fail NotPutBack line 81 81 on failure => fail NotPutBack "the goods held for the order could not be put back" leaving hold
hold: held, posted, voided, expiredhold: handed over as it is: held, posted, voided, expiredfails with the same erroron failure runs to its end, and the workflow fails with the error that started it.
hold: not started, or posted, voided, expiredhold ← reserve(…) out_of_stock → on out_of_stocksucceed outcome = out_of_stock, due = nonehold ← reserve(…) okdue = terms.payment(…) okwait until due.atpayment = check_payment(…) okmatch payment.paid → truehold ← ship(…) oksucceed outcome = shipped, due = due.dayhold ← reserve(…) Dandori.Failure.key_conflict → not handled hereon failurematch hold.state → nonehold ← reserve(…) oknow range >=2026-01-01 <=2027-12-31 now is outside it → not handled hereon failurematch hold.state → heldhold ← put_back(…) already_posted → on already_postedhold ← reserve(…) okdue = terms.payment(…) okwait until due.atpayment = check_payment(…) failure failure failure → not handled hereon failurematch hold.state → heldhold ← put_back(…) okhold ← reserve(…) oknow range >=2026-01-01 <=2027-12-31 now is outside it → not handled hereon failurematch hold.state → heldhold ← put_back(…) expired → on expiredhold ← reserve(…) okdue = terms.payment(…) okwait until due.atpayment = check_payment(…) failure okmatch payment.paid → falsehold ← put_back(…) already_posted → not handled hereon failurematch hold.state → heldhold ← put_back(…) already_posted → on already_postedhold ← reserve(…) okdue = terms.payment(…) okwait until due.atpayment = check_payment(…) okhold ← reserve(…) okdue = terms.payment(…) okwait until due.atpayment = check_payment(…) failure failure failure → not handled hereon failurematch hold.state → heldhold ← put_back(…) okhold ← reserve(…) okdue = terms.payment(…) okwait until due.atpayment = check_payment(…) okmatch payment.paid → falsehold ← put_back(…) oksucceed outcome = not_paid, due = due.dayhold ← reserve(…) okdue = terms.payment(…) okwait until due.atpayment = check_payment(…) failure okmatch payment.paid → truehold ← ship(…) oksucceed outcome = shipped, due = due.dayhold ← reserve(…) okdue = terms.payment(…) okwait until due.atpayment = check_payment(…) okmatch payment.paid → falsehold ← put_back(…) oksucceed outcome = not_paid, due = due.dayhold ← reserve(…) okdue = terms.payment(…) okwait until due.atpayment = check_payment(…) failure okmatch payment.paid → truehold ← ship(…) Dandori.Failure.already_voided → not handled hereon failurematch hold.state → heldhold ← put_back(…) okhold ← reserve(…) okdue = terms.payment(…) okwait until due.atpayment = check_payment(…) okmatch payment.paid → falsehold ← put_back(…) expired → on expiredsucceed outcome = not_paid, due = due.dayhold ← reserve(…) okdue = terms.payment(…) okwait until due.atpayment = check_payment(…) failure okmatch payment.paid → truehold ← ship(…) expired → on expiredsucceed outcome = not_paid, due = due.daynow range >=2026-01-01 <=2027-12-31 now is outside it