diff options
author | Lars Kellogg-Stedman <lars@redhat.com> | 2015-07-16 15:10:07 -0400 |
---|---|---|
committer | Lars Kellogg-Stedman <lars@redhat.com> | 2015-07-17 08:31:54 -0400 |
commit | 2e546f7e26fec006dd18119d4857580ec9ccd540 (patch) | |
tree | 7fc92cce86583dd16827eb0019d6ff56be53c2fd | |
parent | 946eb964adceef7f531ca4f30c4bfe973566811a (diff) | |
download | docker-py-2e546f7e26fec006dd18119d4857580ec9ccd540.tar.gz |
return NotFound on 404 errors
This changes raises docker.errors.NotFound on 404 errors. This gives
client code the ability to differentiate between "an image does not
exist" and "you are using the api incorrectly".
This inherits from docker.errors.APIError so it will not affect any
existing code.
-rw-r--r-- | docker/clientbase.py | 2 | ||||
-rw-r--r-- | docker/errors.py | 4 |
2 files changed, 6 insertions, 0 deletions
diff --git a/docker/clientbase.py b/docker/clientbase.py index c81ee0c..ce52ffa 100644 --- a/docker/clientbase.py +++ b/docker/clientbase.py @@ -99,6 +99,8 @@ class ClientBase(requests.Session): try: response.raise_for_status() except requests.exceptions.HTTPError as e: + if e.response.status_code == 404: + raise errors.NotFound(e, response, explanation=explanation) raise errors.APIError(e, response, explanation=explanation) def _result(self, response, json=False, binary=False): diff --git a/docker/errors.py b/docker/errors.py index d15e332..066406a 100644 --- a/docker/errors.py +++ b/docker/errors.py @@ -53,6 +53,10 @@ class DockerException(Exception): pass +class NotFound(APIError): + pass + + class InvalidVersion(DockerException): pass |