Skip to content

Commit 51b7fa1

Browse files
harlowjaRoach
authored andcommitted
Add http reply into slack login and slack connection error (#216)
Add http reply into slack login and slack connection error
1 parent 661fc5c commit 51b7fa1

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

slackclient/server.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ def rtm_connect(self, reconnect=False, timeout=None, use_rtm_start=True, **kwarg
7272
reply = self.api_requester.do(self.token, connect_method, timeout=timeout, post_data=kwargs)
7373

7474
if reply.status_code != 200:
75-
raise SlackConnectionError
75+
raise SlackConnectionError(reply=reply)
7676
else:
7777
login_data = reply.json()
7878
if login_data["ok"]:
@@ -81,7 +81,7 @@ def rtm_connect(self, reconnect=False, timeout=None, use_rtm_start=True, **kwarg
8181
if not reconnect:
8282
self.parse_slack_login_data(login_data, use_rtm_start)
8383
else:
84-
raise SlackLoginError
84+
raise SlackLoginError(reply=reply)
8585

8686
def parse_slack_login_data(self, login_data, use_rtm_start):
8787
self.login_data = login_data
@@ -112,7 +112,7 @@ def connect_slack_websocket(self, ws_url):
112112
http_proxy_auth=proxy_auth)
113113
self.websocket.sock.setblocking(0)
114114
except Exception as e:
115-
raise SlackConnectionError(str(e))
115+
raise SlackConnectionError(message=str(e))
116116

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

253253

254254
class SlackConnectionError(Exception):
255-
pass
255+
def __init__(self, message='', reply=None):
256+
super(SlackConnectionError, self).__init__(message)
257+
self.reply = reply
256258

257259

258260
class SlackLoginError(Exception):
259-
pass
261+
def __init__(self, message='', reply=None):
262+
super(SlackLoginError, self).__init__(message)
263+
self.reply = reply

0 commit comments

Comments
 (0)