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

Get rid of the diaper pattern (try: except: pass) #51

Open
cwebber opened this issue Oct 6, 2013 · 1 comment
Open

Get rid of the diaper pattern (try: except: pass) #51

cwebber opened this issue Oct 6, 2013 · 1 comment

Comments

@cwebber
Copy link

cwebber commented Oct 6, 2013

keepassc's codebase has the "diaper pattern" all over the place... this is bad form:
http://mike.pirnat.com/2009/05/09/the-diaper-pattern-stinks/

When you use this, it makes it extremely difficult to find bugs. If you throw a keyboard interrupt when the code is moving through this space, it could get caught way down the line, and the code will continue running. So could a network error, a terminal display error, anything.

When catching exceptions, catch something explicitly, or don't catch it at all!

@raymontag
Copy link
Owner

The reason why I used this pattern was that curses crashes if the window is too small. As I added many methods to prevent this case I could remove this pattern but I'll not promise it.

I understand the problem because you have to have an idea where the error occurs to catch a backtrace. I could try to get rid of it slowly and with patience.

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

2 participants