[Workflow] implemented TransitionException to be thrown instead of Logic exception#26587
[Workflow] implemented TransitionException to be thrown instead of Logic exception#26587andrewtch wants to merge 1 commit into
Conversation
| /** | ||
| * @author Andrew Tch <[email protected]> | ||
| */ | ||
| class TransitionException extends \LogicException implements ExceptionInterface |
There was a problem hiding this comment.
could it extend LogicException from the Workflow namespace? this would prevent a BC break
There was a problem hiding this comment.
Oh, so sorry - that was intended to have implement it to avoid BC. Fixed, added a simple test case also.
| /** | ||
| * @author Andrew Tch <[email protected]> | ||
| */ | ||
| class TransitionException extends LogicException implements ExceptionInterface |
There was a problem hiding this comment.
implements ExceptionInterface (since already implemented by LogicException now :)
There was a problem hiding this comment.
Done. Sorry, my coding style is chaotic somehow )
|
Hello @andrewtch Thanks for your PR but unfortunately, It's already implemented in #26076 |
|
@lyrixx , I don't see how I can understand what transition actually caused the exception. Your's UndefinedTransictionException (https://github.com/symfony/symfony/pull/26076/files#diff-edae21a7fe491af4f1bfd5519f01d722) still falls back to simple string. |
|
Can we merge this together to provide a trusted way to differentiate exceptions? |
|
Ok, we will do that ;) |
|
@andrewtch Can you resolve the conflicts here? |
|
@andrewtch If you miss some time to finish this PR before the feature freeze, I can finish it for you. Don't hesitate to tell me. |
|
Thanks @andrewtch for working on this feature. |
…ixx) This PR was merged into the 4.1-dev branch. Discussion ---------- [Workflow] Added a TransitionException | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #26587 #26581 | License | MIT | Doc PR | --- Note for reviewer: `NotEnabledTransitionException` and `UndefinedTransitionException` were not released. So this is not a BC Break. Commits ------- 838548c Finished implementation of TransitionException 9fa4f79 implemented TransitionException to be thrown instead of Logic exception
| /** | ||
| * @return string | ||
| */ | ||
| public function getTransitionName() |
There was a problem hiding this comment.
we could use a return type hint here
| /** | ||
| * @return string | ||
| */ | ||
| public function getWorkflowName() |
Getting Logic exception from Workflow is somehow confusing - as there is no way to understand which transition triggered the exception, and there's no access to the subject being modified to format the exception in any other way.
Therefore, I've implemented TransitionException to be thrown at runtime (extending current LogicException to avoid BC).
getMessagesignature remains the same. All other exceptions are untouched (as they are tied to very logic of the workflow, and to to the subject).See #26581