mift icon indicating copy to clipboard operation
mift copied to clipboard

Long trys with generic excepts will silence unexpected errors

Open cclgroupltd opened this issue 4 years ago • 0 comments

For example: https://github.com/controlf/Smartphone-Image-Forensic-Toolkit-SIFT-/blob/6dc5bb4359d91894cbe2c171437bbd4e36d10504/v1.08/Sift.py#L754

Where possible "try" blocks should be kept to just the code that you expect to raise an exception, and you should be catching the specific types of exception expected.

Writing long try blocks like this, especially paired with a bare except will silence any exception that occurs anywhere in the block, even if it's something you didn't expect (like running out of memory). Silencing with a pass is also not usually a great idea and often logging will be more appropriate (but your mileage may vary based up on the point in the code).

cclgroupltd avatar Feb 04 '22 10:02 cclgroupltd