My activities throw exceptions from time to time during the execution, so I've implemented the Faulted methods of Activity<TInstance>
to handle that, discarding the changes made in the Execute
method. I thought that there's some wiring underneath in Automatonymous that makes it so that the Faulted method executes when the Execute
method throws an exception and then calls the Faulted methods for the activities that were executed already. It turns out that there's no such thing, as my Faulted methods are never executed.
Should I call those myself in a try/catch block instead? I could produce the BehaviorExceptionContextProxy
based on BehaviorContext
and the exception thrown. The only next Behavior
I could pass would be the one inserted into that Activity
's Execute
method, but logically that means I'm compensating in the wrong direction as that next Behavior
is actually to be executed after this one succeeds, so I'd compensate too much.
I also tried to use the Catch
in the state machine, which does handle the exception, however, I couldn't find any way to start the execution of the compensation flow for the activity that failed when I only have the ExceptionActivityBinder
present.
Is there any good way to trigger the compensation flow of the activities?