Permalink
Browse files

Added exception catching for new user?

  • Loading branch information...
1 parent 269844c commit 5acebc8d1c584ce0b35597a6c541f26172d2117e @ahollenbach ahollenbach committed with Jun 20, 2015
Showing with 10 additions and 6 deletions.
  1. +10 −6 User.py
View
16 User.py
@@ -61,12 +61,16 @@ def getUserHandle(self):
Returns true if a user is currently "active", else false
'''
def isActive(self):
- params = {"token": USER_TOKEN_STRING, "user": self.id}
- response = requests.get("https://slack.com/api/users.getPresence",
- params=params)
- status = json.loads(response.text, encoding='utf-8')["presence"]
-
- return status == "active"
+ try:
+ params = {"token": USER_TOKEN_STRING, "user": self.id}
+ response = requests.get("https://slack.com/api/users.getPresence",
+ params=params)
+ status = json.loads(response.text, encoding='utf-8')["presence"]
+
+ return status == "active"
+ except requests.exceptions.ConnectionError:
+ print "Error fetching online status for " + self.getUserHandle()
+ return False
def addExercise(self, exercise, reps):
# Add to total counts

0 comments on commit 5acebc8

Please sign in to comment.