-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Console] Add getters for Application::$autoExit and $catchExceptions #14288
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
What's the use case? |
When the console application is run internally, you probably don't want to log anything - or probably at least in a different manner. By internally I mean that your code invokes a command (something like this) and in this situation, you want to turn off the autoExit feature and also set catchExceptions to false. When an exception occurres you don't want to log this exception as error, because it still might be a valid case which is handled by the calling code. Or even if it isn't, then you would log this error twice - from the internal run and also when it reaches the point from which it was really run - like a controller or another console application run. |
These two flags should only be used for testing commands, and that's why we don't have any getters. I'm 👎 for adding those methods. |
@fabpot what about the cases when you invoke the application internally? Tests are just a special example of this. I think that reusing existing commands is super useful, but inability to reason about the application state complicates the tooling around it (the only way right now is to check via reflection or pass the settings somehow separately through a different channel). |
* | ||
* @api | ||
*/ | ||
public function getCatchExceptions() |
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.
should be areExceptionsCatched()
👍 for master |
10b1a50
to
5be7ed8
Compare
@fabpot thanks for resurfacing this :) I made the chanes you proposed, although I am not sure about the renamings, I tried for them to be as close to the respective setters as possible, which certainly no longer holds with Btw since this PR is so old, it was created against |
* | ||
* @return bool Whether to catch exceptions or not during commands execution | ||
*/ | ||
public function areExceptionsCatched() |
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.
shouldn't this be areExceptionsCaught()
?
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.
indeed
@VasekPurchart Can you fix the typo? |
5be7ed8
to
b1841d8
Compare
@fabpot sure, it's fixed. Should I rebase this somewhere else, as I asked above, or is it fine here? |
@VasekPurchart Can you fix the fabbot issues? No need to rebase, the PR is fine as is. |
@fabpot even if they are completely unrelated to this issue/PR? I thought this would be confusing for the diff. I can do it in a separate commit probably. |
b1841d8
to
4862ed3
Compare
Fixed. |
Thank you @VasekPurchart. |
…catchExceptions (VasekPurchart) This PR was submitted for the 2.7 branch but it was merged into the 3.1-dev branch instead (closes #14288). Discussion ---------- [Console] Add getters for Application::$autoExit and $catchExceptions There is currently no way to retrieve this information from Application (afaik) and since this can be set from outside (and is even part of the `@api`) it should be retrievable. This might come handy for example when working with an Application instance inside your code - for example when creating a Console exception listener - then you need information about how the application was run. | Q | A | ------------- | --- | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - Commits ------- 5d191d3 [Console] Add getters for Application:: and
Thanks for merging! |
There is currently no way to retrieve this information from Application (afaik) and since this can be set from outside (and is even part of the
@api
) it should be retrievable.This might come handy for example when working with an Application instance inside your code - for example when creating a Console exception listener - then you need information about how the application was run.