jrxFive / python-nomad

Client library Hashicorp Nomad
https://python-nomad.readthedocs.io/en/latest/
MIT License
139 stars 73 forks source link

Exception not requests.Response with BaseNomadException str dunder #109

Closed jonathanrcross closed 4 years ago

jonathanrcross commented 4 years ago

Addressing #107, add safety checks to verify that the passed parameter of nomad_resp is a requests.Response object if it is not cast str around exception with different message.

Not a huge fan of have a conditional str with different messages (along with checking for certain substrings as a test) but this should at least fix the bug and ensure somewhat backwards compatibility. Technically text in requests.Response is not a guarantee either since its kwargs are popped for response and request and can possibly be None.

If we do eventually move to python 3+ only support adding annotations should help a bunch when visually inspecting or even mypy level runtime checking.