hoprnet / hoprd-sdk-python

Native Python wrapper around the HOPR daemon API
3 stars 7 forks source link

Add re-raise to exception for higher level handling #14

Closed jeandemeusy closed 1 year ago

jeandemeusy commented 1 year ago

The call_api() method handles httpx exceptions, but the exceptions need to be re-raised, to that they can be managed on a higher level.

jeandemeusy commented 1 year ago

I implemented something following your idea @Teebor-Choka I think. Now, call_api() has the same behaviour as before, except is never raise an exception. _safe_call_api() make a call to call_api() and raises an exception if necessary. Thus the wrapper is not impacted by the change, and I can handle the exception on a higher level.

Teebor-Choka commented 1 year ago

I implemented something following your idea @Teebor-Choka I think. Now, call_api() has the same behaviour as before, except is never raise an exception. _safe_call_api() make a call to call_api() and raises an exception if necessary. Thus the wrapper is not impacted by the change, and I can handle the exception on a higher level.

Semantically, it should be the other way around - _safe_api is used by all other methods and does not throw. The call_api throws. _safe_api calls the call_api.