averbis / averbis-python-api

Conveniently access the REST API of Averbis products using Python
Apache License 2.0
12 stars 4 forks source link

Check connection validity when creating the client #53

Closed reckart closed 3 years ago

reckart commented 3 years ago

Is your feature request related to a problem? Please describe. When I create the client with the wrong URL, there can be cryptic error messages like:

__request(self, method, endpoint, **kwargs)
    520         raw_response = self._run_request(method, endpoint, **kwargs)
    521 
--> 522         response = raw_response.json()
    523         self.__handle_error(response)
    524         return response

These indicate that the server responds but does not provide JSON.

Describe the solution you'd like

reckart commented 3 years ago

Actually, one can just call client.ensureAvailable().