automat
automat copied to clipboard
How to handle errors occurring during outputs?
Unfortunately, our world is filled with side-effects which are out of our control and can result in errors. Based on a short chat with @glyph exceptions occurring when executing outputs will just bubble up resulting the machine to be in an unexpected state. What is the best way to handle this? Would an API to move to another state on error make sense? Maybe an example with current API will be nice.
One major problem here is that if a transition requires multiple outputs, and one of them that isn't the last one fails, what happens to the un-called outputs? Do we blindly proceed along, calling each one, and just noticing if it fails? Do we put it into the new state even if the exception prevented execution of the later outputs? It seems difficult to preserve any useful invariants once an unexpected exception has interrupted some code in the middle.
Right now, I think the best practice for automat is "don't have errors" :-).