Return more precise error description when adding to aspects
authorJason Robinson <jaywink@basshero.org>
Sun, 30 Jun 2013 21:52:03 +0000 (00:52 +0300)
committerJason Robinson <jaywink@basshero.org>
Sun, 30 Jun 2013 21:52:03 +0000 (00:52 +0300)
diaspy/models.py

index ec798cc709e60fbae4fc566b4671283cdc4aecc0..3fbfd7db530dded00f2fa91096b1f02bb891e831 100644 (file)
@@ -30,7 +30,11 @@ class Aspect():
 
         request = self._connection.post('aspect_memberships.json', data=data)
 
-        if request.status_code != 201:
+        if request.status_code == 400:
+            raise Exception('duplicate record, user already exists in aspect: {0}'.format(request.status_code))
+        elif request.status_code == 404:
+            raise Exception('user not found from this pod: {0}'.format(request.status_code))
+        elif request.status_code != 201:
             raise Exception('wrong status code: {0}'.format(request.status_code))
         return request.json()