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

Commit

Permalink
exception handling around json parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
aerickson committed May 11, 2017
1 parent 3ec618d commit 08e0feb
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions rtmbot/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,16 @@ def output(self):
message = output[1]
# things that start with U are users. convert to an IM channel.
if destination.startswith('U'):
result = json.loads(self.slack_client.api_call('im.open', user=destination))
try:
result = json.loads(self.slack_client.api_call('im.open', user=destination))
except ValueError:
self._dbg("Parse error on im.open call results!")
channel = self.slack_client.server.channels.find(result[u'channel'][u'id'])
elif destination.startswith('G'):
result = json.loads(self.slack_client.api_call('groups.open'), channel=destination))
try:
result = json.loads(self.slack_client.api_call('groups.open'), channel=destination))
except ValueError:
self._dbg("Parse error on groups.open call results!")
channel = self.slack_client.server.channels.find(result[u'channel'][u'id'])
else:
channel = self.slack_client.server.channels.find(destination)
Expand Down

0 comments on commit 08e0feb

Please sign in to comment.