8000 [DX][Console] Use specific exception classes for not defined and ambiguous command names · Issue #14873 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content
8000

[DX][Console] Use specific exception classes for not defined and ambiguous command names #14873

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
GromNaN opened this issue Jun 5, 2015 · 2 comments
Labels

Comments

@GromNaN
Copy link
Member
GromNaN commented Jun 5, 2015

The method Console\Application::find can throw an \InvalidArgumentException when the command name typed is not defined or ambiguous.

To avoid having such exception logged into my alert system I want to filter on these exceptions. But the class \InvalidArgumentException is too generic.

What about creating a domain specific class: Symfony\Component\Console\Exception\CommandNotDefinedException extending \InvalidArgumentException ?

As a bonus, this exception class would have an extra property $alternatives to store the suggested command names.

@stof stof added the Console label Jun 5, 2015
@stof
Copy link
Member
stof commented Jun 5, 2015

This looks like a good idea to me.

Can you submit a PR to implement it in 2.8 ?

@GromNaN
Copy link
Member Author
GromNaN commented Jun 6, 2015

I'm doing it: #14894.

fabpot added a commit that referenced this issue Sep 25, 2015
…eptions (GromNaN)

This PR was squashed before being merged into the 2.8 branch (closes #14894).

Discussion
----------

[Console] Add domain exceptions to replace generic exceptions

Creates domain specific exception classes for the case where a user type an invalid command name or option name.

| Q             | A
| ------------- | ---
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #14873
| License       | MIT
| Doc PR        | N/A

TODO:
* [x] Replace `\InvalidArgumentException` by `Symfony\Component\Console\Exception\InvalidArgumentException`
* [x] Add `Symfony\Component\Console\Exception\ExceptionInterface`

Commits
-------

dd17dc0 [Console] Add domain exceptions to replace generic exceptions
@fabpot fabpot closed this as completed Sep 25, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants
0