When an HTTP GET request fails, it's useful to go beyond the "not
successful" message, and show the code returned by the server.
Signed-off-by: Cleber Rosa <crosa@redhat.com>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Wainer dos Santos Moschetta <wainersm@redhat.com>
Message-Id: <
20210222193240.921250-3-crosa@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
connection.request('GET', url=url)
response = connection.getresponse()
if response.code != http.HTTPStatus.OK:
- raise CommunicationFailure("Failed to receive a successful response")
+ msg = "Received unsuccessful response: %s (%s)" % (response.code,
+ response.reason)
+ raise CommunicationFailure(msg)
return json.loads(response.read())