Do Not Use Bare Except¶
Sourcery suggestion id:
except: Exception rather than bare
try: some_important_code() except: exception_handling_code()
try: some_important_code() except Exception: exception_handling_code()
we should avoid catching exceptions using a bare
The problem with these is that they catch
exceptions, which makes it harder to interrupt a program using CTRL+C, and can
also disguise other problems.
The PEP recommends catching
Exception, which will catch all program errors, so
that is what Sourcery suggests. Note that this suggestion does not trigger if
the exception handler ends by raising the original exception.