Skip to content
This repository was archived by the owner on Aug 15, 2022. It is now read-only.

Commit 08e0feb

Browse files
committed
exception handling around json parsing
1 parent 3ec618d commit 08e0feb

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

rtmbot/core.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,16 @@ def output(self):
120120
message = output[1]
121121
# things that start with U are users. convert to an IM channel.
122122
if destination.startswith('U'):
123-
result = json.loads(self.slack_client.api_call('im.open', user=destination))
123+
try:
124+
result = json.loads(self.slack_client.api_call('im.open', user=destination))
125+
except ValueError:
126+
self._dbg("Parse error on im.open call results!")
124127
channel = self.slack_client.server.channels.find(result[u'channel'][u'id'])
125128
elif destination.startswith('G'):
126-
result = json.loads(self.slack_client.api_call('groups.open'), channel=destination))
129+
try:
130+
result = json.loads(self.slack_client.api_call('groups.open'), channel=destination))
131+
except ValueError:
132+
self._dbg("Parse error on groups.open call results!")
127133
channel = self.slack_client.server.channels.find(result[u'channel'][u'id'])
128134
else:
129135
channel = self.slack_client.server.channels.find(destination)

0 commit comments

Comments
 (0)