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

Appearance settings

[Finder] InvalidArgumentException for non-existing directory #30723

Copy link
Copy link
Closed
@xelan

Description

@xelan
Issue body actions

Symfony version(s) affected: all supported versions

Description
Finder::in() throws an InvalidArgumentException when one of the directories is not found. However, a valid directory name for a directory which does not exist is IMHO a normal case for the Finder and not an invalid argument. Therefore, non-existing directories should throw an dedicated Exception of the Finder component instead of the generic InvalidArgumentException.
This would also simplify catching such exceptions.

How to reproduce

require_once('vendor/autoload.php');
$f = new Symfony\Component\Finder\Finder();
$f->directories()->in('no');

Throws InvalidArgumentException although the argument is a valid directory name. A dedicated exception which can be specifically caught would be more useful and improve DX.

Possible Solution
Create a dedicated DirectoryNotFoundException, which extends InvalidArgumentException for BC. Later it would probably make more sense to extend RuntimeException instead.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.