MCPcopy Index your code
hub / github.com/docker/docker-py / create_api_error_from_http_exception

Function create_api_error_from_http_exception

docker/errors.py:22–39  ·  view source on GitHub ↗

Create a suitable APIError from requests.exceptions.HTTPError.

(e)

Source from the content-addressed store, hash-verified

20
21
22def create_api_error_from_http_exception(e):
23 """
24 Create a suitable APIError from requests.exceptions.HTTPError.
25 """
26 response = e.response
27 try:
28 explanation = response.json()['message']
29 except ValueError:
30 explanation = (response.text or '').strip()
31 cls = APIError
32 if response.status_code == 404:
33 explanation_msg = (explanation or '').lower()
34 if any(fragment in explanation_msg
35 for fragment in _image_not_found_explanation_fragments):
36 cls = ImageNotFound
37 else:
38 cls = NotFound
39 raise cls(e, response=response, explanation=explanation) from e
40
41
42class APIError(requests.exceptions.HTTPError, DockerException):

Callers 2

_raise_for_statusMethod · 0.85

Calls

no outgoing calls

Tested by 1