Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Throw exception with meaningful error description in case of missing state definition. #15

Merged
merged 12 commits into from May 29, 2019

Conversation

pchmielowski
Copy link
Contributor

When a state definition is missing, exception is thrown with message: Required value is null.
This fix adds more meaningful error message.

An example of missing state definition:

            private val stateMachine = StateMachine.create<String, Int, Nothing> {
                initialState(STATE_A)
                state(STATE_A) {
                    on(EVENT_1) {
                        transitionTo(STATE_B)
                    }
                }
                // Missing STATE_B definition.
            }

Error is thrown here:

stateMachine.transition(EVENT_1) // transition to `STATE_B` which is not handled.

Copy link
Collaborator

@lfernandosp lfernandosp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM overall! It just needs some idiomatic tweaks.
Thank you for your initiative.

src/test/kotlin/com/tinder/StateMachineTest.kt Outdated Show resolved Hide resolved
src/test/kotlin/com/tinder/StateMachineTest.kt Outdated Show resolved Hide resolved
src/main/kotlin/com/tinder/StateMachine.kt Outdated Show resolved Hide resolved
@lfernandosp lfernandosp merged commit e45485d into Tinder:master May 29, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants