sdk-go
sdk-go copied to clipboard
OnError - how to tell whether Transition or End is defined (which to use)?
What is the question: Since the OnError struct defines both Transition & End as struct and not pointers, how should i check if either is "defined" since i can't check for nil?
We can change that to a pointer
instead so you can check it for nil
.
actually, i am currently check if Transition.NextState is empty string to infer that Transition is not defined, which then implies it is End. Not sure if this is the right approach.
In spec transition/end are mutually exclusive. If both are present, its a validation error that should be caught at compile time imo.
the checks are really, if end exists, and its value is true then its ending state. If transition exists and its value is not empty, its a transition. if both exist well then you didnt validate the dsl :)
There can be an additional check for transitions at validation/compile time to make sure that the state its trying to transition to actually exists.
Also note that Switch states are unique their end/transition definitions should be in conditions / default condition. We might need to fix the schema for that for 0.9 if its not clear.
Same rules for checking transition/end also applies to onError defs