VNG-Realisatie / gemma-zds-client

2 stars 4 forks source link

Add `status_code` attribute to `ClientError` #26

Closed Viicos closed 2 years ago

Viicos commented 2 years ago

To handle exceptions on open-objects, I need to get the correct status code when an exception is raised in the client class.

As the ClientError exception is raised from the requests.HTTPError, I'm still able to get the status code this way:

try:
    object = client.retrieve(...)
except ClientError as err:
    print(err.__cause__.response.status_code)

But it would be great to have it accessible on the ClientError instead (or we could use the whole response as well, instead of just the status code).