glyph / automat

Self-service finite-state machines for the programmer on the go.
MIT License
591 stars 65 forks source link

exception handling for `TypeMachine` #160

Open glyph opened 2 months ago

glyph commented 2 months ago

Right now, if a behavior function raises an exception, there are cases where a TypeMachine will end up in an inconsistent state.

In particular, if a data factory raises an exception, it will do this after the machine has already transitioned to the state that expects the data to be populated. As such, this exception will leave the TypeMachine in a persistently broken state, and worse, one which will be receiving the wrong type of object to its behavior functions (most likely a None, I think, although possibly a previous data-state's object sometimes?)

A few changes need to be made: