Skip to content
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

Exception improvements #33

Closed
moufmouf opened this issue Oct 11, 2018 · 8 comments
Closed

Exception improvements #33

moufmouf opened this issue Oct 11, 2018 · 8 comments

Comments

@moufmouf
Copy link
Member

When catching Exception, Throwable or RuntimeException, we should ensure that the exception is always rethrown (or wrapped into another exception that is thrown).

@moufmouf
Copy link
Member Author

TODO: need to update README.

@moufmouf
Copy link
Member Author

  • need to add the context in the error message.

@moufmouf
Copy link
Member Author

and need to update the neon file.

@odan
Copy link

odan commented Nov 2, 2018

Rethrowing exceptions is a rare use case for me, because my middleware has to catch and handle them anyway. By the way: I've heard that rethrowing exceptions is considered an anti-pattern (catch, log, throw again).

How can I disable this rule?

@moufmouf
Copy link
Member Author

moufmouf commented Nov 2, 2018

Indeed, if you are developing a middleware, this specific rule does not apply.
I'm planning to add "parameters" to enable or disable specific rules but I haven't done that yet.

In the meantime, you can ignore the error message with a regular expression: https://github.com/phpstan/phpstan#ignore-error-messages-with-regular-expressions

@juliangut
Copy link

@moufmouf ability to disable certain rules in a way such as PHPMD and other does would be really appreciated as well. I might want to disable a rule for a specific use case in a class (knowing what I'm doing) but leave it on for the rest of the code base

If you find this appealing an issue can be created to discuss what and how

@moufmouf
Copy link
Member Author

moufmouf commented Nov 6, 2018

@juliangut I would absolutely love to have the possibility to disable a rule for a specific use case (a specific method or class) but I believe this ability should be part of PHPStan (and not the phpstan-strict-rules extension). Maybe open an issue to PHPStan?

@juliangut
Copy link

You're right!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants