Add response url to Server Error and Client Error messages

Signed-off-by: Yuval Goldberg <yuvigoldi@hotmail.com>
This commit is contained in:
Yuval Goldberg 2020-08-16 18:54:14 +03:00 committed by YuvalG
parent 30ff9f339c
commit 3766f77c20
1 changed files with 6 additions and 4 deletions

View File

@ -46,12 +46,14 @@ class APIError(requests.exceptions.HTTPError, DockerException):
message = super(APIError, self).__str__()
if self.is_client_error():
message = '{0} Client Error: {1}'.format(
self.response.status_code, self.response.reason)
message = '{0} Client Error for {1}: {2}'.format(
self.response.status_code, self.response.url,
self.response.reason)
elif self.is_server_error():
message = '{0} Server Error: {1}'.format(
self.response.status_code, self.response.reason)
message = '{0} Server Error for {1}: {2}'.format(
self.response.status_code, self.response.url,
self.response.reason)
if self.explanation:
message = '{0} ("{1}")'.format(message, self.explanation)