Reserve stock
FreeLogic@rabbinatix/reserve-stock by Rabbinatixupdated Oct 4, 2026
Takes items from stock, or explains why it can't, without failing the caller.
Inside Try, asking for more than there is fires Throw Error (OUT_OF_STOCK). Catch keeps the error message, and Finally returns in both cases.
Shows: Try / Catch / Finally, Throw Error with a code and message, the error pin, Is Null.
How to use it
Add it to your logic, then add a Call Function step in any logic and pick Reserve stock. It belongs to no system, so every system can use it. Or download the TypeScript and call it from your own code.
Inputs
stock: Whole number
wanted: Whole number
Outputs
ok: Yes / No
left: Number (may be empty)
error: Text (may be empty)
Previewdrag the steps around; scroll to zoom
Function Entry, Input / output. 0 inputs, 3 outputs. step 1 of 14
Reserve stock
stock
wanted
Try / Catch, Flow control. 1 input, 4 outputs. step 2 of 14
Try / Catch
Try
Catch
error
Finally
Greater Than, Operators. 2 inputs, 1 output. step 3 of 14
>
A
B
result
Branch, Flow control. 2 inputs, 2 outputs. step 4 of 14
Branch
condition
True
False
Format, String. 1 input, 1 output. step 5 of 14
Format "Only {stock} left"
stock
result
Throw Error, Flow control. 2 inputs, 0 outputs. step 6 of 14
Throw Error
message
Subtract, Operators. 2 inputs, 1 output. step 7 of 14
-
A
B
result
Set Variable, Data. 2 inputs, 2 outputs. step 8 of 14
Set left
value
value
Get Property, Object. 1 input, 2 outputs. step 9 of 14
Get .message
object
message
exists
Set Variable, Data. 2 inputs, 2 outputs. step 10 of 14
Set error
value
value
Get Variable, Data. 0 inputs, 1 output. step 11 of 14
Get left
value
Get Variable, Data. 0 inputs, 1 output. step 12 of 14
Get error
value
Is Null, Validation. 1 input, 1 output. step 13 of 14
Is Null
value
result
Return, Input / output. 4 inputs, 0 outputs. step 14 of 14
Return
ok
left
error
Arrow keys: next or previous step in flow order. Alt with arrows: nearest step in that direction. Enter: open. Shift F10: more actions.
Examplesrun live against the logic · 2/2 pass
| Passed | Example | Input | Output |
|---|---|---|---|
| In stock | {"stock":5,"wanted":2} | {"ok":true,"left":3,"error":null} | |
| Not enough | {"stock":1,"wanted":3} | {"ok":false,"left":null,"error":"Only 1 left"} |
Try it
Versions
In this package
Reserve stock (entry)
