Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Favor LogicException for missing classes & functions#28536

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
nicolas-grekas merged 1 commit intosymfony:masterfromro0NL:validator
Sep 24, 2018
Merged

Favor LogicException for missing classes & functions#28536

nicolas-grekas merged 1 commit intosymfony:masterfromro0NL:validator
Sep 24, 2018

Conversation

@ro0NL
Copy link
Contributor

QA
Branch?master
Bug fix?no
New feature?yes-ish
BC breaks?no-ish
Deprecations?no
Tests pass?yes
Fixed tickets#28513 (comment)
LicenseMIT
Doc PRsymfony/symfony-docs#...

if (Email::VALIDATION_MODE_STRICT ===$constraint->mode) {
if (!class_exists('\Egulias\EmailValidator\EmailValidator')) {
thrownewRuntimeException('Strict email validation requires egulias/email-validator ~1.2|~2.0');
thrownewLogicException('Strict email validation requires egulias/email-validator ~1.2|~2.0');
Copy link
Member

Choose a reason for hiding this comment

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

That's a BC break as LogicException does not extend RuntimeException. Not sure it is worth it.

Choose a reason for hiding this comment

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

True, but nobody can rely on this exception being thrown because a package is missing, don't you think?

Copy link
Member

Choose a reason for hiding this comment

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

True, but I don't see why Logic is better than Runtime. We are using Runtime for such exceptions on the Messenger component for instance and Logic on some other components.

Copy link
Member

@nicolas-grekasnicolas-grekasSep 24, 2018
edited
Loading

Choose a reason for hiding this comment

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

To me, a logic exception means the code is broken (composer.json here): it's a programmer mistake. Runtime exception means some unexpected behavior was observed (e.g. broken connection, etc.)

ro0NL, Koc, chalasr, and ogizanagi reacted with thumbs up emoji
Copy link
Member

Choose a reason for hiding this comment

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

Works for me, but we should fixed this across the board then.

nicolas-grekas reacted with thumbs up emoji
Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Done.

thrownewLogicException('To enable the locking feature you must install the symfony/lock component.');
}

if (null !==$this->lock) {
Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

theLogicException below looks odd :)

Choose a reason for hiding this comment

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

you mean we should return true instead?@jderusse WDYT?
@ro0NL up for a PR on 3.4 to trigger the discussion?

Choose a reason for hiding this comment

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

on 2.8 actually? and unrelated to the Lock component, I was too fast :)

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

just curious if it should be Runtime.. though Logic might be valid if the developer should call in specific order.

Choose a reason for hiding this comment

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

yep, that makes sense also, asking devs to take care and pointing their mistake otherwise with LogicException

Copy link
Member

Choose a reason for hiding this comment

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

This method should not be called twice. IMHO, this is a developer's misconception and should be a LogicException

ro0NL reacted with thumbs up emoji
/**
* @author Roland Franssen <franssen.roland@gmail.com>
*/
class LogicExceptionextends \LogicExceptionimplements ExceptionInterface
Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

added to not downgrade from namespaced to root namespace exception

@ro0NLro0NL changed the title[Validator] Leverage new LogicExceptionFavor LogicException for missing classes & functionsSep 24, 2018
@nicolas-grekas
Copy link
Member

Thank you@ro0NL.

@nicolas-grekasnicolas-grekas merged commitc762735 intosymfony:masterSep 24, 2018
nicolas-grekas added a commit that referenced this pull requestSep 24, 2018
…ro0NL)This PR was merged into the 4.2-dev branch.Discussion----------Favor LogicException for missing classes & functions| Q             | A| ------------- | ---| Branch?       | master| Bug fix?      | no| New feature?  | yes-ish| BC breaks?    | no-ish     <!-- seehttps://symfony.com/bc -->| Deprecations? | no| Tests pass?   | yes    <!-- please add some, will be required by reviewers -->| Fixed tickets |#28513 (comment)| License       | MIT| Doc PR        | symfony/symfony-docs#... <!-- required for new features --><!--Write a short README entry for your feature/bugfix here (replace this comment block.)This will help people understand your PR and can be used as a start of the Doc PR.Additionally: - Bug fixes must be submitted against the lowest branch where they apply   (lowest branches are regularly merged to upper ones so they get the fixes too). - Features and deprecations must be submitted against the master branch.-->Commits-------c762735 Favor LogicException for missing classes & functions
@ro0NLro0NL deleted the validator branchSeptember 24, 2018 08:36
@nicolas-grekasnicolas-grekas modified the milestones:next,4.2Nov 1, 2018
This was referencedNov 3, 2018
gido added a commit to antistatique/symfony that referenced this pull requestDec 27, 2018
fancyweb added a commit that referenced this pull requestJun 5, 2023
…nglet)This PR was merged into the 5.4 branch.Discussion----------[DomCrawler] Fix Crawler::filter throw phpdoc| Q             | A| ------------- | ---| Branch?       | 5.4| Bug fix?      | not really (phpdoc-fix)| New feature?  | no| Deprecations? | no| Tickets       | Fix #... <!-- prefix each issue number with "Fix #", no need to create an issue if none exists, explain below instead -->| License       | MIT| Doc PR        | symfony/symfony-docs#... <!-- required for new features -->The `Crawler::filter` method is calling```$converter = $this->createCssSelectorConverter();```which is throwing a `LogicException` since#28536So the phpdoc should be````@throws` \LogicException if the CssSelector Component is not available```and not````@throws` \RuntimeException if the CssSelector Component is not available```Commits-------ae19695 Fix Crawler::filter throw phpdoc
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@fabpotfabpotfabpot left review comments

@nicolas-grekasnicolas-grekasnicolas-grekas approved these changes

@jderussejderussejderusse left review comments

Assignees

No one assigned

Projects

None yet

Milestone

4.2

Development

Successfully merging this pull request may close these issues.

5 participants

@ro0NL@nicolas-grekas@fabpot@jderusse@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp