Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Workflow] implemented TransitionException to be thrown instead of Logic exception #26587

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

Closed
wants to merge 1 commit into from
Closed

[Workflow] implemented TransitionException to be thrown instead of Logic exception #26587

wants to merge 1 commit into from

Conversation

andrewtch
Copy link
Contributor

Q A
Branch? master
Bug fix? no
New feature? yes
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets
License MIT
Doc PR

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). getMessage signature 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

@nicolas-grekas nicolas-grekas changed the title implemented TransitionException to be thrown instead of Logic exception [Workflow] implemented TransitionException to be thrown instead of Logic exception Mar 19, 2018
@nicolas-grekas nicolas-grekas added this to the 4.1 milestone Mar 19, 2018
/**
* @author Andrew Tch <[email protected]>
*/
class TransitionException extends \LogicException implements ExceptionInterface
Copy link
Member

Choose a reason for hiding this comment

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

could it extend LogicException from the Workflow namespace? this would prevent a BC break

Copy link
Contributor Author

Choose a reason for hiding this comment

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

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
Copy link
Member

Choose a reason for hiding this comment

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

implements ExceptionInterface (since already implemented by LogicException now :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done. Sorry, my coding style is chaotic somehow )

@lyrixx
Copy link
Member

lyrixx commented Mar 19, 2018

Hello @andrewtch

Thanks for your PR but unfortunately, It's already implemented in #26076

@andrewtch
Copy link
Contributor Author

@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.

@andrewtch
Copy link
Contributor Author

Can we merge this together to provide a trusted way to differentiate exceptions?

@lyrixx
Copy link
Member

lyrixx commented Mar 19, 2018

Ok, we will do that ;)

@xabbuh
Copy link
Member

xabbuh commented Mar 21, 2018

@andrewtch Can you resolve the conflicts here?

@lyrixx
Copy link
Member

lyrixx commented Mar 21, 2018

@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.

@lyrixx
Copy link
Member

lyrixx commented Mar 23, 2018

Thanks @andrewtch for working on this feature.
The feature freeze is almost here. That's why I finished your PR: #26651

@lyrixx lyrixx closed this Mar 23, 2018
lyrixx added a commit that referenced this pull request Mar 23, 2018
…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()
Copy link
Member

Choose a reason for hiding this comment

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

we could use a return type hint here

Copy link
Member

Choose a reason for hiding this comment

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

You commented a closed pr :-)

/**
* @return string
*/
public function getWorkflowName()
Copy link
Member

Choose a reason for hiding this comment

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

same here

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.

4 participants