From 2281d4fb20b7d66948043d33aa632e5d7c1efb3a Mon Sep 17 00:00:00 2001 From: qmuntal Date: Fri, 14 May 2021 10:49:02 +0200 Subject: [PATCH] add error handling documentation --- statemachine.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/statemachine.go b/statemachine.go index dff0bd5..5f9dfbf 100644 --- a/statemachine.go +++ b/statemachine.go @@ -228,6 +228,13 @@ func (sm *StateMachine) Fire(trigger Trigger, args ...interface{}) error { // FireCtx transition from the current state via the specified trigger. // The target state is determined by the configuration of the current state. // Actions associated with leaving the current state and entering the new one will be invoked. +// +// An error is returned if any of the state machine actions or the state callbacks return an error +// without wrapping. It can also return an error if the trigger is not mapped to any state change, +// being this error the one returned by `OnUnhandledTrigger` func. +// +// There is no rollback mechanism in case there is an action error after the state has been changed. +// Guard clauses or error states can be used gracefully handle this situations. func (sm *StateMachine) FireCtx(ctx context.Context, trigger Trigger, args ...interface{}) error { return sm.internalFire(ctx, trigger, args...) }