Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

outgoing_webhook: Simplify error handling logic.

Tim Abbott88f351cdeeef
diff --git a/zerver/lib/outgoing_webhook.py b/zerver/lib/outgoing_webhook.py
index dbcd1cf33c8..75f56b64320 100644
--- a/zerver/lib/outgoing_webhook.py
+++ b/zerver/lib/outgoing_webhook.py
@@ -241,23 +241,23 @@ def notify_bot_owner(
assert bot_owner is not None
notification_message = f"[A message]({message_url}) to your bot @_**{bot.full_name}** triggered an outgoing webhook."
- if failure_message:
+ if exception:
+ notification_message += (
+ "\nWhen trying to send a request to the webhook service, an exception "
+ f"of type {type(exception).__name__} occurred:\n```\n{exception}\n```"
+ )
+ elif failure_message:
notification_message += "\n" + failure_message
- if status_code == 407:
+ elif status_code == 407:
notification_message += (
"\nThe URL configured for the webhook is for a private or disallowed network."
)
elif status_code:
notification_message += f"\nThe webhook got a response with status code *{status_code}*."
- if response_content and status_code != 407:
- notification_message += (
- f"\nThe response contains the following payload:\n```\n{response_content!r}\n```"
- )
- if exception:
- notification_message += (
- "\nWhen trying to send a request to the webhook service, an exception "
- f"of type {type(exception).__name__} occurred:\n```\n{exception}\n```"
- )
+ if response_content:
+ notification_message += (
+ f"\nThe response contains the following payload:\n```\n{response_content!r}\n```"
+ )
message_info = dict(
type="private",