Skip to content

Throw QueueStateIsEmptyException when entering next state from empty queue - #22

Merged
Red-Cat-Fat merged 1 commit into
developfrom
codex/add-queue-empty-check-before-dequeue
Feb 13, 2026
Merged

Throw QueueStateIsEmptyException when entering next state from empty queue#22
Red-Cat-Fat merged 1 commit into
developfrom
codex/add-queue-empty-check-before-dequeue

Conversation

@Red-Cat-Fat

Copy link
Copy Markdown
Owner

Motivation

  • Prevent calling Dequeue() on an empty _queue and provide a clear, diagnosable error when EnterNextFromQueue() is invoked with no queued states.
  • Include the state machine name in the error to simplify troubleshooting which machine raised the condition.

Description

  • Add QueueStateIsEmptyException to Packages/StateMachine/Exceptions with a StateMachineName field and an error message containing the machine name.
  • Update BaseTypedStateMachine.EnterNextFromQueue() to check if (_queue.Count == 0) and throw QueueStateIsEmptyException(_name) before calling Dequeue().
  • Extend Packages/StateMachine/Tests/ExceptionStateMachineTests.cs with GivenStateMachine_WhenEnterNextFromEmptyQueue_ThenCatchQueueStateIsEmptyException to assert the new exception type and that the exception message contains the state machine name.

Testing

  • No automated test runner was executed in this environment because the Unity/NUnit test runner is unavailable here, so the new NUnit test was added but not executed.
  • A code search for QueueStateIsEmptyException and EnterNextFromQueue( was run to verify usages and changes were applied successfully.

Codex Task

@Red-Cat-Fat
Red-Cat-Fat merged commit 2096951 into develop Feb 13, 2026
4 checks passed
@Red-Cat-Fat
Red-Cat-Fat deleted the codex/add-queue-empty-check-before-dequeue branch February 13, 2026 09:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant