Closed lexuzieel closed 2 years ago
It appears that currently there seems no way to get the error returned from PermitDynamic.
In my code I return an error using the following code:
fsm.Configure("prompt"). PermitDynamic("step", func(ctx context.Context, args ...interface{}) (stateless.State, error) { code := args[0].(string) if code != "bar" { return "prompt", errors.New("invalid code") } return "apply", nil })
in my test I fire a transition:
err := fsm.Fire("step", "foo") assert.ErrorContains(t, err, "invalid code")
and get:
Error "stateless: Dynamic handler for trigger step in state prompt has failed" does not contain "invalid code"
I suppose this is a bug and when firing a transition, an error should be overwritten?
Thanks for reporting this bug. I'll fix it in the next patch release.
It appears that currently there seems no way to get the error returned from PermitDynamic.
In my code I return an error using the following code:
in my test I fire a transition:
and get:
I suppose this is a bug and when firing a transition, an error should be overwritten?