suplemon icon indicating copy to clipboard operation
suplemon copied to clipboard

Except statement should be narrower (catch exactly what is expected)

Open Gnewbee opened this issue 8 years ago • 3 comments
trafficstars

Maybe the top level exception handling could redirect to the logger but the low level stuff should not be that broad.

Gnewbee avatar Sep 10 '17 21:09 Gnewbee

It's broad in some places intentionally, but there's probably many that don't need to be. Could you provide some specific examples?

richrd avatar Sep 21 '17 06:09 richrd

A very quick search, so probably not the best example but simply in the cli module,

try:
    import argparse
except:
    # Python < 2.7
argparse = False

should be catching ImportError, no reason to catch broader. I'll do a systematic search and a pull request on dev as soon as I have some free time.

Gnewbee avatar Oct 05 '17 12:10 Gnewbee

Ok! I did a quick search too and found lots of "catch all" except statements. I'll also try to fix them slowly but surely while I work on other things.

richrd avatar Oct 06 '17 07:10 richrd