Kaydet (Commit) 2e546f7e authored tarafından Lars Kellogg-Stedman's avatar Lars Kellogg-Stedman

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.
üst 946eb964
...@@ -99,6 +99,8 @@ class ClientBase(requests.Session): ...@@ -99,6 +99,8 @@ class ClientBase(requests.Session):
try: try:
response.raise_for_status() response.raise_for_status()
except requests.exceptions.HTTPError as e: 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) raise errors.APIError(e, response, explanation=explanation)
def _result(self, response, json=False, binary=False): def _result(self, response, json=False, binary=False):
......
...@@ -53,6 +53,10 @@ class DockerException(Exception): ...@@ -53,6 +53,10 @@ class DockerException(Exception):
pass pass
class NotFound(APIError):
pass
class InvalidVersion(DockerException): class InvalidVersion(DockerException):
pass pass
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment