diff options
author | Ben Firshman <ben@firshman.co.uk> | 2016-09-14 14:53:04 +0100 |
---|---|---|
committer | Ben Firshman <ben@firshman.co.uk> | 2016-09-14 14:54:40 +0100 |
commit | dcd01f0f48525e4d5bb4953f1f57a7a65e424561 (patch) | |
tree | e58e2311d27dbd7493fe40df8a435f47743c3de3 /docker/errors.py | |
parent | e676840945217d47b510bbc1c3232c1228fb809a (diff) | |
download | docker-py-dcd01f0f48525e4d5bb4953f1f57a7a65e424561.tar.gz |
Parse JSON API errors
Signed-off-by: Ben Firshman <ben@firshman.co.uk>
Diffstat (limited to 'docker/errors.py')
-rw-r--r-- | docker/errors.py | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/docker/errors.py b/docker/errors.py index 97be802..df18d57 100644 --- a/docker/errors.py +++ b/docker/errors.py @@ -11,7 +11,10 @@ class APIError(requests.exceptions.HTTPError): self.explanation = explanation if self.explanation is None and response.content: - self.explanation = response.content.strip() + try: + self.explanation = response.json()['message'] + except ValueError: + self.explanation = response.content.strip() def __str__(self): message = super(APIError, self).__str__() |