-
-
Notifications
You must be signed in to change notification settings - Fork 9.8k
[Console] Add domain exceptions to replace generic exceptions #14894
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
Closed
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
7b2c75f
[Console] Add CommandNotDefinedException to replace generic \InvalidA…
GromNaN 64aae63
[Console] Add InvalidOptionException to replace generic \InvalidArgum…
GromNaN 185e506
Use CommandNotDefinedException in ApplicationDescription
GromNaN 63f5af6
[Console] Use domain specific exceptions
GromNaN 882ad75
Rename CommandNotDefinedException to CommandNotFoundException for con…
GromNaN File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
src/Symfony/Component/Console/Exception/CommandNotFoundException.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| <?php | ||
|
|
||
| /* | ||
| * This file is part of the Symfony package. | ||
| * | ||
| * (c) Fabien Potencier <fabien@symfony.com> | ||
| * | ||
| * For the full copyright and license information, please view the LICENSE | ||
| * file that was distributed with this source code. | ||
| */ | ||
|
|
||
| namespace Symfony\Component\Console\Exception; | ||
|
|
||
| /** | ||
| * Represents an incorrect command name typed in the console. | ||
| * | ||
| * @author Jérôme Tamarelle <jerome@tamarelle.net> | ||
| */ | ||
| class CommandNotFoundException extends \InvalidArgumentException implements ExceptionInterface | ||
| { | ||
| private $alternatives; | ||
|
|
||
| /** | ||
| * @param string $message Exception message to throw. | ||
| * @param array $alternatives List of similar defined names. | ||
| * @param int $code Exception code. | ||
| * @param Exception $previous previous exception used for the exception chaining. | ||
| */ | ||
| public function __construct($message, array $alternatives = array(), $code = 0, \Exception $previous = null) | ||
| { | ||
| parent::__construct($message, $code, $previous); | ||
|
|
||
| $this->alternatives = $alternatives; | ||
| } | ||
|
|
||
| /** | ||
| * @return array A list of similar defined names. | ||
| */ | ||
| public function getAlternatives() | ||
| { | ||
| return $this->alternatives; | ||
| } | ||
| } |
23 changes: 23 additions & 0 deletions
23
src/Symfony/Component/Console/Exception/ExceptionInterface.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| <?php | ||
|
|
||
| /* | ||
| * This file is part of the Symfony package. | ||
| * | ||
| * (c) Fabien Potencier <fabien@symfony.com> | ||
| * | ||
| * For the full copyright and license information, please view the LICENSE | ||
| * file that was distributed with this source code. | ||
| */ | ||
|
|
||
| namespace Symfony\Component\Console\Exception; | ||
|
|
||
| /** | ||
| * ExceptionInterface. | ||
| * | ||
| * @author Jérôme Tamarelle <jerome@tamarelle.net> | ||
| * | ||
| * @api | ||
| */ | ||
| interface ExceptionInterface | ||
| { | ||
| } | ||
19 changes: 19 additions & 0 deletions
19
src/Symfony/Component/Console/Exception/InvalidArgumentException.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| <?php | ||
|
|
||
| /* | ||
| * This file is part of the Symfony package. | ||
| * | ||
| * (c) Fabien Potencier <fabien@symfony.com> | ||
| * | ||
| * For the full copyright and license information, please view the LICENSE | ||
| * file that was distributed with this source code. | ||
| */ | ||
|
|
||
| namespace Symfony\Component\Console\Exception; | ||
|
|
||
| /** | ||
| * @author Jérôme Tamarelle <jerome@tamarelle.net> | ||
| */ | ||
| class InvalidArgumentException extends \InvalidArgumentException implements ExceptionInterface | ||
| { | ||
| } |
21 changes: 21 additions & 0 deletions
21
src/Symfony/Component/Console/Exception/InvalidOptionException.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| <?php | ||
|
|
||
| /* | ||
| * This file is part of the Symfony package. | ||
| * | ||
| * (c) Fabien Potencier <fabien@symfony.com> | ||
| * | ||
| * For the full copyright and license information, please view the LICENSE | ||
| * file that was distributed with this source code. | ||
| */ | ||
|
|
||
| namespace Symfony\Component\Console\Exception; | ||
|
|
||
| /** | ||
| * Represents an incorrect option name typed in the console. | ||
| * | ||
| * @author Jérôme Tamarelle <jerome@tamarelle.net> | ||
| */ | ||
| class InvalidOptionException extends \InvalidArgumentException implements ExceptionInterface | ||
| { | ||
| } |
19 changes: 19 additions & 0 deletions
19
src/Symfony/Component/Console/Exception/LogicException.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| <?php | ||
|
|
||
| /* | ||
| * This file is part of the Symfony package. | ||
| * | ||
| * (c) Fabien Potencier <fabien@symfony.com> | ||
| * | ||
| * For the full copyright and license information, please view the LICENSE | ||
| * file that was distributed with this source code. | ||
| */ | ||
|
|
||
| namespace Symfony\Component\Console\Exception; | ||
|
|
||
| /** | ||
| * @author Jérôme Tamarelle <jerome@tamarelle.net> | ||
| */ | ||
| class LogicException extends \LogicException implements ExceptionInterface | ||
| { | ||
| } |
19 changes: 19 additions & 0 deletions
19
src/Symfony/Component/Console/Exception/RuntimeException.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| <?php | ||
|
|
||
| /* | ||
| * This file is part of the Symfony package. | ||
| * | ||
| * (c) Fabien Potencier <fabien@symfony.com> | ||
| * | ||
| * For the full copyright and license information, please view the LICENSE | ||
| * file that was distributed with this source code. | ||
| */ | ||
|
|
||
| namespace Symfony\Component\Console\Exception; | ||
|
|
||
| /** | ||
| * @author Jérôme Tamarelle <jerome@tamarelle.net> | ||
| */ | ||
| class RuntimeException extends \RuntimeException implements ExceptionInterface | ||
| { | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we really need the interface? And do we need to tag it with as an
@apiinterface given that the exception class are not tagged this way?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It needs to be consistent with the way we manage exception in the other components. We can indeed remove the
@apitag but I'm not sure this will ever change.