From c5e41a94e2f08b7f659ce6c3e930785515efc6df Mon Sep 17 00:00:00 2001 From: Jason Robinson Date: Mon, 1 Jul 2013 00:52:03 +0300 Subject: [PATCH] Return more precise error description when adding to aspects --- diaspy/models.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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() -- 2.25.1