Skip to content

Commit 82a5794

Browse files
minor #57705 [Workflow] Clearer NotEnabledTransitionException message (that-guy-iain)
This PR was squashed before being merged into the 7.2 branch. Discussion ---------- [Workflow] Clearer `NotEnabledTransitionException` message | Q | A | ------------- | --- | Branch? | 7.2 | Bug fix? | no | New feature? | yes | Deprecations? | no | License | MIT The current exception message is somewhat confusing as it makes you think the transition is not enabled at all within the workflow. This can/does lead to people trying to debug a config issue. While the problem being encountered issue is that the transition can't be applied due to the current state of the supported class/object. Hopefully, this makes it a bit clearer. Commits ------- 942ca5acc2 [Workflow] Clearer `NotEnabledTransitionException` message
2 parents a370dba + 2147e68 commit 82a5794

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

Exception/NotEnabledTransitionException.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
use Symfony\Component\Workflow\WorkflowInterface;
1616

1717
/**
18-
* Thrown by Workflow when a not enabled transition is applied on a subject.
18+
* Thrown when a transition cannot be applied on a subject.
1919
*
2020
* @author Grégoire Pineau <[email protected]>
2121
*/
@@ -28,7 +28,7 @@ public function __construct(
2828
private TransitionBlockerList $transitionBlockerList,
2929
array $context = [],
3030
) {
31-
parent::__construct($subject, $transitionName, $workflow, \sprintf('Transition "%s" is not enabled for workflow "%s".', $transitionName, $workflow->getName()), $context);
31+
parent::__construct($subject, $transitionName, $workflow, \sprintf('Cannot apply transition "%s" on workflow "%s".', $transitionName, $workflow->getName()), $context);
3232
}
3333

3434
public function getTransitionBlockerList(): TransitionBlockerList

Tests/WorkflowTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ public function testApplyWithNotEnabledTransition()
286286

287287
$this->fail('Should throw an exception');
288288
} catch (NotEnabledTransitionException $e) {
289-
$this->assertSame('Transition "t2" is not enabled for workflow "unnamed".', $e->getMessage());
289+
$this->assertSame('Cannot apply transition "t2" on workflow "unnamed".', $e->getMessage());
290290
$this->assertCount(1, $e->getTransitionBlockerList());
291291
$list = iterator_to_array($e->getTransitionBlockerList());
292292
$this->assertSame('The marking does not enable the transition.', $list[0]->getMessage());

0 commit comments

Comments
 (0)