raymontag / keepassc

KeePassC is a curses-based password manager compatible to KeePass v.1.x and KeePassX
http://raymontag.github.com/keepassc/
ISC License
310 stars 23 forks source link

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

Open cwebber opened 11 years ago

cwebber commented 11 years ago

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 commented 11 years ago

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.