keepassc icon indicating copy to clipboard operation
keepassc copied to clipboard

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

Open cwebber opened this issue 12 years ago • 1 comments

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!

cwebber avatar Oct 06 '13 23:10 cwebber

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.

raymontag avatar Oct 13 '13 12:10 raymontag