mirror of
https://github.com/ansible/awx.git
synced 2026-05-12 03:47:36 -02:30
Merge pull request #4433 from ghjm/webhook_error_detail
Error detail in webhook and credential tests
This commit is contained in:
@@ -1397,7 +1397,7 @@ class CredentialExternalTest(SubDetailAPIView):
|
|||||||
obj.credential_type.plugin.backend(**backend_kwargs)
|
obj.credential_type.plugin.backend(**backend_kwargs)
|
||||||
return Response({}, status=status.HTTP_202_ACCEPTED)
|
return Response({}, status=status.HTTP_202_ACCEPTED)
|
||||||
except requests.exceptions.HTTPError as exc:
|
except requests.exceptions.HTTPError as exc:
|
||||||
message = 'HTTP {}\n{}'.format(exc.response.status_code, exc.response.text)
|
message = 'HTTP {}'.format(exc.response.status_code)
|
||||||
return Response({'inputs': message}, status=status.HTTP_400_BAD_REQUEST)
|
return Response({'inputs': message}, status=status.HTTP_400_BAD_REQUEST)
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
return Response({'inputs': str(exc)}, status=status.HTTP_400_BAD_REQUEST)
|
return Response({'inputs': str(exc)}, status=status.HTTP_400_BAD_REQUEST)
|
||||||
|
|||||||
@@ -99,8 +99,8 @@ class GrafanaBackend(AWXBaseEmailBackend, CustomNotificationBase):
|
|||||||
headers=grafana_headers,
|
headers=grafana_headers,
|
||||||
verify=(not self.grafana_no_verify_ssl))
|
verify=(not self.grafana_no_verify_ssl))
|
||||||
if r.status_code >= 400:
|
if r.status_code >= 400:
|
||||||
logger.error(smart_text(_("Error sending notification grafana: {}").format(r.text)))
|
logger.error(smart_text(_("Error sending notification grafana: {}").format(r.status_code)))
|
||||||
if not self.fail_silently:
|
if not self.fail_silently:
|
||||||
raise Exception(smart_text(_("Error sending notification grafana: {}").format(r.text)))
|
raise Exception(smart_text(_("Error sending notification grafana: {}").format(r.status_code)))
|
||||||
sent_messages += 1
|
sent_messages += 1
|
||||||
return sent_messages
|
return sent_messages
|
||||||
|
|||||||
@@ -47,8 +47,8 @@ class HipChatBackend(AWXBaseEmailBackend, CustomNotificationBase):
|
|||||||
"from": m.from_email,
|
"from": m.from_email,
|
||||||
"message_format": "text"})
|
"message_format": "text"})
|
||||||
if r.status_code != 204:
|
if r.status_code != 204:
|
||||||
logger.error(smart_text(_("Error sending messages: {}").format(r.text)))
|
logger.error(smart_text(_("Error sending messages: {}").format(r.status_code)))
|
||||||
if not self.fail_silently:
|
if not self.fail_silently:
|
||||||
raise Exception(smart_text(_("Error sending message to hipchat: {}").format(r.text)))
|
raise Exception(smart_text(_("Error sending message to hipchat: {}").format(r.status_code)))
|
||||||
sent_messages += 1
|
sent_messages += 1
|
||||||
return sent_messages
|
return sent_messages
|
||||||
|
|||||||
@@ -46,8 +46,8 @@ class MattermostBackend(AWXBaseEmailBackend, CustomNotificationBase):
|
|||||||
r = requests.post("{}".format(m.recipients()[0]),
|
r = requests.post("{}".format(m.recipients()[0]),
|
||||||
json=payload, verify=(not self.mattermost_no_verify_ssl))
|
json=payload, verify=(not self.mattermost_no_verify_ssl))
|
||||||
if r.status_code >= 400:
|
if r.status_code >= 400:
|
||||||
logger.error(smart_text(_("Error sending notification mattermost: {}").format(r.text)))
|
logger.error(smart_text(_("Error sending notification mattermost: {}").format(r.status_code)))
|
||||||
if not self.fail_silently:
|
if not self.fail_silently:
|
||||||
raise Exception(smart_text(_("Error sending notification mattermost: {}").format(r.text)))
|
raise Exception(smart_text(_("Error sending notification mattermost: {}").format(r.status_code)))
|
||||||
sent_messages += 1
|
sent_messages += 1
|
||||||
return sent_messages
|
return sent_messages
|
||||||
|
|||||||
@@ -46,9 +46,9 @@ class RocketChatBackend(AWXBaseEmailBackend, CustomNotificationBase):
|
|||||||
|
|
||||||
if r.status_code >= 400:
|
if r.status_code >= 400:
|
||||||
logger.error(smart_text(
|
logger.error(smart_text(
|
||||||
_("Error sending notification rocket.chat: {}").format(r.text)))
|
_("Error sending notification rocket.chat: {}").format(r.status_code)))
|
||||||
if not self.fail_silently:
|
if not self.fail_silently:
|
||||||
raise Exception(smart_text(
|
raise Exception(smart_text(
|
||||||
_("Error sending notification rocket.chat: {}").format(r.text)))
|
_("Error sending notification rocket.chat: {}").format(r.status_code)))
|
||||||
sent_messages += 1
|
sent_messages += 1
|
||||||
return sent_messages
|
return sent_messages
|
||||||
|
|||||||
@@ -72,8 +72,8 @@ class WebhookBackend(AWXBaseEmailBackend, CustomNotificationBase):
|
|||||||
headers=self.headers,
|
headers=self.headers,
|
||||||
verify=(not self.disable_ssl_verification))
|
verify=(not self.disable_ssl_verification))
|
||||||
if r.status_code >= 400:
|
if r.status_code >= 400:
|
||||||
logger.error(smart_text(_("Error sending notification webhook: {}").format(r.text)))
|
logger.error(smart_text(_("Error sending notification webhook: {}").format(r.status_code)))
|
||||||
if not self.fail_silently:
|
if not self.fail_silently:
|
||||||
raise Exception(smart_text(_("Error sending notification webhook: {}").format(r.text)))
|
raise Exception(smart_text(_("Error sending notification webhook: {}").format(r.status_code)))
|
||||||
sent_messages += 1
|
sent_messages += 1
|
||||||
return sent_messages
|
return sent_messages
|
||||||
|
|||||||
Reference in New Issue
Block a user