Skip to content

Commit

Permalink
Add http reply into slack login and slack connection error (#216)
Browse files Browse the repository at this point in the history
Add http reply into slack login and slack connection error
  • Loading branch information
harlowja authored and Roach committed Oct 9, 2017
1 parent 661fc5c commit 51b7fa1
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions slackclient/server.py
Expand Up @@ -72,7 +72,7 @@ def rtm_connect(self, reconnect=False, timeout=None, use_rtm_start=True, **kwarg
reply = self.api_requester.do(self.token, connect_method, timeout=timeout, post_data=kwargs)

if reply.status_code != 200:
raise SlackConnectionError
raise SlackConnectionError(reply=reply)
else:
login_data = reply.json()
if login_data["ok"]:
Expand All @@ -81,7 +81,7 @@ def rtm_connect(self, reconnect=False, timeout=None, use_rtm_start=True, **kwarg
if not reconnect:
self.parse_slack_login_data(login_data, use_rtm_start)
else:
raise SlackLoginError
raise SlackLoginError(reply=reply)

def parse_slack_login_data(self, login_data, use_rtm_start):
self.login_data = login_data
Expand Down Expand Up @@ -112,7 +112,7 @@ def connect_slack_websocket(self, ws_url):
http_proxy_auth=proxy_auth)
self.websocket.sock.setblocking(0)
except Exception as e:
raise SlackConnectionError(str(e))
raise SlackConnectionError(message=str(e))

def parse_channel_data(self, channel_data):
for channel in channel_data:
Expand Down Expand Up @@ -252,8 +252,12 @@ def api_call(self, method, timeout=None, **kwargs):


class SlackConnectionError(Exception):
pass
def __init__(self, message='', reply=None):
super(SlackConnectionError, self).__init__(message)
self.reply = reply


class SlackLoginError(Exception):
pass
def __init__(self, message='', reply=None):
super(SlackLoginError, self).__init__(message)
self.reply = reply

0 comments on commit 51b7fa1

Please sign in to comment.