-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
Limit and remove panic usage in the code. #7409
Comments
Where do we explicitly panic in tests?! We shouldn't be doing this. I'm not aware of any places where we do this.
Yes, obviously returning errors as far upstream as possible is ideal, and there are a few places where we panic that we should not (e.g. CLI, client-code, REST handlers maybe, etc...). BUT, the panics found in the modules (i.e. state-machine) are explicit and meant to panic! Those are not to be removed. |
Here is a list of places where we panic in tests: https://pastebin.com/jKmQv3Ug Here is the list of all places where we panic. It's huge. Mostly in modules, but also in |
Cool, thanks for compiling that. We should definitely address the tests. |
closing in favour of #15555 |
Summary
There are many (a lot!) places in the SDK code which are susceptible for panics.
The general Go recommendation is to not use panics whenever possible.
Problem Definition
We should avoid panics whenever possible. The Go team deliberately limited the exception mechanism for good reasons: they are not designed to rigorously check code on each step and can leave an app in a wrong state if not managed properly.
From Go FAQ:
Rob Pike on a "Proposal for an exception-like mechanism"
Proposal
Look through the code and remove panics wherever possible.
testing.T.Fail / Fatal
methods.panic
log.Fatal
Discussions
Incremental issues
For Admin Use
The text was updated successfully, but these errors were encountered: