USEPA / esupy

A library supporting Python-based tools in USEPA's tool ecosystem
5 stars 2 forks source link

tweaked error handling in make_url_request #35

Closed matthewlchambers closed 2 years ago

matthewlchambers commented 2 years ago

What I was thinking was an if: ... else: ... inside the except: block, as seen here. You make a good point about the requests.exceptions.RequestException error being more generic than HTTPError and ConnectionError, but it turns out that HTTPError and ConnectionError both inherit from RequestException, so we can use a single except: clause to handle all of them.

Also, when we use raise in an except: block without specifying what exception to raise, it will just re-raise whatever exception the except: block caught, which I think is desirable behavior so we don't lose information by raising a generic exceptio instead of the specific exception that actually happened.