Skip to content
Snippets Groups Projects
Commit b3c2fa39 authored by Tulir Asokan's avatar Tulir Asokan :cat2:
Browse files

Reply with error if webhook creation fails

parent af018940
No related branches found
No related tags found
No related merge requests found
Pipeline #6114 passed
......@@ -33,6 +33,7 @@ class GitHubError(Exception):
self.documentation_url = documentation_url
self.status = status
self.kwargs = kwargs
self.message = message
class GraphQLError(Exception):
......
......@@ -258,9 +258,18 @@ class Commands:
# TODO webhook may be deleted on github side
return
webhook = self.bot.webhook_manager.create(repo_name, evt.sender, evt.room_id)
await client.create_webhook(*repo, url=self.bot.webapp_url / "webhook" / str(webhook.id),
secret=webhook.secret, content_type="json", events=["*"])
await evt.reply(f"Successfully created webhook for {repo_name}")
try:
await client.create_webhook(
*repo, url=self.bot.webapp_url / "webhook" / str(webhook.id),
secret=webhook.secret,
content_type="json",
events=["*"],
)
except GitHubError as e:
await evt.reply(f"Failed to create webhook: {e.message}")
self.bot.webhook_manager.delete(webhook.id)
else:
await evt.reply(f"Successfully created webhook for {repo_name}")
@webhook.subcommand("remove", aliases=["delete", "rm", "del"])
@command.argument("repo", required=True, matches=repo_syntax, label="owner/repo")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment