From 51b7fa1b748459f88622b482128350b3472dbf42 Mon Sep 17 00:00:00 2001 From: Joshua Harlow Date: Mon, 9 Oct 2017 16:21:14 -0700 Subject: [PATCH] Add http reply into slack login and slack connection error (#216) Add http reply into slack login and slack connection error --- slackclient/server.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/slackclient/server.py b/slackclient/server.py index 3c1f814f5..f6b105665 100644 --- a/slackclient/server.py +++ b/slackclient/server.py @@ -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"]: @@ -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 @@ -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: @@ -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