Skip to content

[Finder] Throw a dedicated exception for non-existing directory #30744

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

Merged
merged 1 commit into from
Mar 30, 2019
Merged

[Finder] Throw a dedicated exception for non-existing directory #30744

merged 1 commit into from
Mar 30, 2019

Conversation

xelan
Copy link
Contributor

@xelan xelan commented Mar 28, 2019

Q A
Branch? master
Bug fix? yes [1]
New feature? yes
BC breaks? no
Deprecations? no [2]
Tests pass? yes
Fixed tickets #30723
License MIT
Doc PR N/A [3]

Makes Finder::in() throw a DirectoryNotFoundException instead of an InvalidArgumentException if one of the directories is not found.
This behavior is more consistent with the AccessDeniedException for files which are unreadable due to insufficient permissions.
To keep backward compatibility, the new exception class inherits from InvalidArgumentException.

[1] A valid, but non-existent directory name is IMHO not an invalid argument
[2] However, it may be semantically better to extend from RuntimeException, This would require a deprecation.
[3] Possible exceptions are currently not explained at https://symfony.com/doc/current/components/finder.html

Makes Finder::in() throw a DirectoryNotFoundException instead of an InvalidArgumentException if one of the directories is not found.
This behavior is more consistent with the AccessDeniedException for files which are unreadable due to insufficient permissions.
To keep BC, the new exception class inherits from InvalidArgumentException.
@nicolas-grekas nicolas-grekas added this to the next milestone Mar 28, 2019
@fabpot
Copy link
Member

fabpot commented Mar 30, 2019

Thank you @xelan.

@fabpot fabpot merged commit 48d5f94 into symfony:master Mar 30, 2019
fabpot added a commit that referenced this pull request Mar 30, 2019
…directory (xelan)

This PR was merged into the 4.3-dev branch.

Discussion
----------

[Finder] Throw a dedicated exception for non-existing directory

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | yes [1]
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no [2]
| Tests pass?   | yes
| Fixed tickets | #30723
| License       | MIT
| Doc PR        | N/A [3]

Makes `Finder::in()` throw a `DirectoryNotFoundException` instead of an `InvalidArgumentException` if one of the directories is not found.
This behavior is more consistent with the `AccessDeniedException` for files which are unreadable due to insufficient permissions.
To keep backward compatibility, the new exception class inherits from `InvalidArgumentException`.

[1] A valid, but non-existent directory name is IMHO not an invalid argument
[2] However, it may be semantically better to extend from `RuntimeException`,  This would require a deprecation.
[3] Possible exceptions are currently not explained at https://symfony.com/doc/current/components/finder.html

Commits
-------

48d5f94 Throw a dedicated exception for non-existing directory
@nicolas-grekas nicolas-grekas modified the milestones: next, 4.3 Apr 30, 2019
@fabpot fabpot mentioned this pull request May 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants