summaryrefslogtreecommitdiff
path: root/docker/errors.py
diff options
context:
space:
mode:
authorBen Firshman <ben@firshman.co.uk>2016-09-14 14:53:04 +0100
committerBen Firshman <ben@firshman.co.uk>2016-09-14 14:54:40 +0100
commitdcd01f0f48525e4d5bb4953f1f57a7a65e424561 (patch)
treee58e2311d27dbd7493fe40df8a435f47743c3de3 /docker/errors.py
parente676840945217d47b510bbc1c3232c1228fb809a (diff)
downloaddocker-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.py5
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__()