aboutsummaryrefslogtreecommitdiffstats
path: root/slack
diff options
context:
space:
mode:
authorTrygve Aaberge <trygveaa@gmail.com>2023-08-19 11:44:08 +0200
committerTrygve Aaberge <trygveaa@gmail.com>2024-02-18 11:32:53 +0100
commit94733110f491c02b6b6ac30fe3095eabb56fa6b4 (patch)
tree06060aa9d20d29b216454361912d6dcb396ed43a /slack
parentab6dfe135825c9287d2522c581315fe9ecb0cc2e (diff)
downloadwee-slack-94733110f491c02b6b6ac30fe3095eabb56fa6b4.tar.gz
Handle failed rtm.connect response
Diffstat (limited to 'slack')
-rw-r--r--slack/slack_workspace.py16
1 files changed, 14 insertions, 2 deletions
diff --git a/slack/slack_workspace.py b/slack/slack_workspace.py
index d28083e..7e001a9 100644
--- a/slack/slack_workspace.py
+++ b/slack/slack_workspace.py
@@ -15,7 +15,12 @@ from websocket import (
create_connection,
)
-from slack.error import SlackError, SlackRtmError, store_and_format_exception
+from slack.error import (
+ SlackApiError,
+ SlackError,
+ SlackRtmError,
+ store_and_format_exception,
+)
from slack.log import print_error
from slack.proxy import Proxy
from slack.shared import shared
@@ -195,7 +200,14 @@ class SlackWorkspace:
self._connect_task = None
async def _connect(self) -> None:
- rtm_connect = await self.api.fetch_rtm_connect()
+ try:
+ rtm_connect = await self.api.fetch_rtm_connect()
+ except SlackApiError as e:
+ print_error(
+ f'failed connecting to workspace "{self.name}": {e.response["error"]}'
+ )
+ return
+
self.id = rtm_connect["team"]["id"]
self.enterprise_id = rtm_connect["team"].get("enterprise_id")
self.my_user = await self.users[rtm_connect["self"]["id"]]