OceanNetworksCanada / api-python-client

Provides easy access to ONC data in Python
https://oceannetworkscanada.github.io/api-python-client/
Apache License 2.0
10 stars 9 forks source link

Improve exception types raised and caught #17

Closed Jacob-Stevens-Haas closed 9 months ago

Jacob-Stevens-Haas commented 9 months ago

See #3. There are 19 cases of except Exception and 11 of `raise Exception. Python's philosophy is to raise the most specific error possible so that exception handlers and humans have the most information possible. The way to achieve this is via:

In addition, a lot of code uses the antipattern:

try:
     do something
except Exception:
    raise

which does the same thing as

do something

Out of scope for this issue but also germane is the use of internal status-passing with integer codes, rather than raising an exception.

Ref: https://docs.python.org/3/library/exceptions.html