Skip to content

Fixes some too-generic exceptions

John Douglas Veitch requested to merge john-veitch/pesummary:exceptions into master

It is bad practice to catch or raise generic exceptions. If you do something like this

try:
    blah()
except Exception:
    raise Exception("Apparently helpful message")

it actually makes debugging much more difficult, because I can't see what the real problem is. If you want to catch or raise a specific exception then you can do that with the right type (see built-in exceptions).

In general you should only catch a specific exception if the code can handle it. You should not use exceptions instead of if..then blocks either.

Basically you should never create or catch an Exception class! Unfortunately there are a lot more than the ones I've fixed here.

Merge request reports