From: Jason Robinson Date: Sun, 30 Jun 2013 21:52:03 +0000 (+0300) Subject: Return more precise error description when adding to aspects X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=c5e41a94e2f08b7f659ce6c3e930785515efc6df;p=diaspy.git Return more precise error description when adding to aspects --- diff --git a/diaspy/models.py b/diaspy/models.py index ec798cc..3fbfd7d 100644 --- a/diaspy/models.py +++ b/diaspy/models.py @@ -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()