aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjason2016-09-06 18:50:19 -0600
committerjason2016-09-06 18:50:19 -0600
commit2497a398a916fdacf5540ca6a2c60fc3c8d29e7f (patch)
tree9672b293723cd78b0c02c3d559d7beda2231f736
parent13bc4770fd7f314debd0e16b4ae52f68b6779330 (diff)
downloadwarmachine-ng-2497a398a916fdacf5540ca6a2c60fc3c8d29e7f.tar.gz
warmachine-ng-2497a398a916fdacf5540ca6a2c60fc3c8d29e7f.zip
Don't crash when getting an unknown error from Slack
- Slack takes their site down to do database migrations and returns an api error while this is happening. This catches the error when authenticating and returns so that it can (hopefully) continue to reconnect.
-rw-r--r--warmachine/connections/slack.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/warmachine/connections/slack.py b/warmachine/connections/slack.py
index 26113b9..116a540 100644
--- a/warmachine/connections/slack.py
+++ b/warmachine/connections/slack.py
@@ -4,6 +4,7 @@ import logging
4from pprint import pformat 4from pprint import pformat
5from urllib.parse import urlencode 5from urllib.parse import urlencode
6import urllib.request 6import urllib.request
7import sys
7 8
8import websockets 9import websockets
9 10
@@ -46,7 +47,11 @@ class SlackWS(Connection):
46 return md5(self.token.encode()).hexdigest() 47 return md5(self.token.encode()).hexdigest()
47 48
48 async def connect(self): 49 async def connect(self):
49 self.host = self.authenticate() 50 try:
51 self.host = self.authenticate()
52 except Exception:
53 self.log.exception('Error authenticating to slack')
54 return
50 self.log.info('Connecting to {}'.format(self.host)) 55 self.log.info('Connecting to {}'.format(self.host))
51 self.ws = await websockets.connect(self.host) 56 self.ws = await websockets.connect(self.host)
52 self.STATUS = CONNECTED 57 self.STATUS = CONNECTED