Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[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

Closed

Conversation

VasekPurchart
Copy link
Contributor

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 -

@unkind
Copy link
Contributor

unkind commented Apr 9, 2015

for example when creating a Console exception listener - then you need information about how the application was run

What's the use case?

@VasekPurchart
Copy link
Contributor Author

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.

@xabbuh xabbuh added the Console label Apr 21, 2015
@fabpot
Copy link
Member

fabpot commented May 16, 2015

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.

@VasekPurchart
Copy link
Contributor Author

@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()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be areExceptionsCatched()

@fabpot
Copy link
Member

fabpot commented Jan 25, 2016

👍 for master

@VasekPurchart VasekPurchart force-pushed the application-exit-getters branch from 10b1a50 to 5be7ed8 Compare January 25, 2016 14:13
@VasekPurchart
Copy link
Contributor Author

@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 setCatchExceptions vs areExceptionsCatched (even if you guess are, the word order is different). But if this is in alignment with other SF APIs, then it's of course, just wasn't sure.

Btw since this PR is so old, it was created against 2.7, should I try to open it against another version or master as you wrote? I could easily rebase this although it seems there is no way to change the branch here on GitHub.

*
* @return bool Whether to catch exceptions or not during commands execution
*/
public function areExceptionsCatched()
Copy link
Contributor

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()?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indeed

@fabpot
Copy link
Member

fabpot commented Jan 27, 2016

@VasekPurchart Can you fix the typo?

@VasekPurchart VasekPurchart force-pushed the application-exit-getters branch from 5be7ed8 to b1841d8 Compare January 27, 2016 11:07
@VasekPurchart
Copy link
Contributor Author

@fabpot sure, it's fixed. Should I rebase this somewhere else, as I asked above, or is it fine here?

@fabpot
Copy link
Member

fabpot commented Jan 27, 2016

@VasekPurchart Can you fix the fabbot issues? No need to rebase, the PR is fine as is.

@VasekPurchart
Copy link
Contributor Author

@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.

@VasekPurchart VasekPurchart force-pushed the application-exit-getters branch from b1841d8 to 4862ed3 Compare January 27, 2016 11:18
@VasekPurchart
Copy link
Contributor Author

Fixed.

@fabpot
Copy link
Member

fabpot commented Jan 27, 2016

Thank you @VasekPurchart.

@fabpot fabpot closed this Jan 27, 2016
fabpot added a commit that referenced this pull request Jan 27, 2016
…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
@VasekPurchart
Copy link
Contributor Author

Thanks for merging!

@VasekPurchart VasekPurchart deleted the application-exit-getters branch January 27, 2016 11:29
@fabpot fabpot mentioned this pull request May 13, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants