Return early from handle_rtmstart on failure
This makes the error case a bit clearer and easier to read.
@@ -2033,7 +2033,11 @@ def handle_rtmstart(login_data, eventrouter):
"""
metadata = pickle.loads(login_data["wee_slack_request_metadata"])
- if login_data["ok"]:
+ if not login_data["ok"]:
+ w.prnt("", "ERROR: Failed connecting to Slack with token {}: {}"
+ .format(metadata.token, login_data["error"]))
+ return
+
# Let's reuse a team if we have it already.
th = SlackTeam.generate_team_hash(login_data['self']['name'], login_data['team']['domain'])
if not eventrouter.teams.get(th):
@@ -2102,10 +2106,6 @@ def handle_rtmstart(login_data, eventrouter):
dbg("connected to {}".format(t.domain))
- else:
- w.prnt("", "ERROR: Failed connecting to Slack with token {}: {}"
- .format(metadata.token, login_data["error"]))
-
# self.identifier = self.domain
def handle_channelsinfo(channel_json, eventrouter, **kwargs):
