-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[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
Conversation
|
||
[Symfony\Component\Console\Exception\CommandNotDefinedException] | ||
Command "foo" is not define | ||
d. |
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.
I'm not sure this is the correct behavior. The line is wrapped, but not the class name, and the rest of the line is filled with spaces.
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.
I think d
should be on the same line as define
.
557e52d
to
bd025a3
Compare
bd025a3
to
0077045
Compare
Any idea how to fix this failing test ?
|
AFAIK, the alternative names was originally ordered with |
{ | ||
return $this->alternatives; | ||
} | ||
} |
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.
Please, check missing new lines at EOFs.
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.
Fixed.
0077045
to
c367dc8
Compare
c367dc8
to
b09375b
Compare
@@ -176,7 +176,7 @@ public function testSilentHelp() | |||
} | |||
|
|||
/** | |||
* @expectedException \InvalidArgumentException | |||
* @expectedException Symfony\Component\Console\Exception\CommandNotDefinedException |
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.
Missing leading \ on all @expectedException
tags
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.
Can you fix this? We are using a leading \
everywhere else in Symfony for such PHPUnit annotations.
As you are moving exceptions to specific ones, what about doing it for the whole component? |
@GromNaN Any news on this one? Can you address the comments? |
OK for moving remaining exception to specific ones. Is it necessary to keep the distinction between |
Yes, I think we need to keep the distinction here (at least to keep BC). |
I'll create And the interface |
ae7d14d
to
515f392
Compare
Replace exception thrown by specific exception implementing the same interface.
515f392
to
63f5af6
Compare
Rebased and made all changes. I still have this error on HHVM :
|
* | ||
* @author Jérôme Tamarelle <jerome@tamarelle.net> | ||
*/ | ||
class CommandNotDefinedException extends \InvalidArgumentException implements ExceptionInterface |
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.
I would have named it CommandNotFoundException
to be more consistent with other exception names in other components.
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.
That's close to the RouteNotFoundException
from the Routing component. Have you something in mind ?
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.
CommandNotFoundException
I made some minor comments, but I'm 👍 on this change. ping @symfony/deciders |
@@ -38,7 +39,7 @@ public function ask(InputInterface $input, OutputInterface $output, Question $qu | |||
|
|||
// make required | |||
if (!is_array($value) && !is_bool($value) && 0 === strlen($value)) { | |||
throw new \Exception('A value is required.'); | |||
throw new LogicException('A value is required.'); |
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.
Here I've replaced the only instance of the basic \Exception
by a more precise LogicException
.
👍 |
Thank you @GromNaN. |
…test (xabbuh) This PR was merged into the 2.8 branch. Discussion ---------- [Console] don't rely on internal sort implementation om test | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #14894 | License | MIT | Doc PR | PHP does not guarantuee how array elements with the same value will be sorted when applying `asort()`. Since all namespaces used in the test produce the same Levenshtein value, we should only check for presence of these namespaces instead of comparing the exact order. Commits ------- 3011fa0 don't rely on internal sort implementation in test
Creates domain specific exception classes for the case where a user type an invalid command name or option name.
TODO:
\InvalidArgumentException
bySymfony\Component\Console\Exception\InvalidArgumentException
Symfony\Component\Console\Exception\ExceptionInterface