Revision 8fe6475a snf-astakos-client/astakosclient/__init__.py

b/snf-astakos-client/astakosclient/__init__.py
53 53
        return repr(self.message)
54 54

  
55 55

  
56
class AstakosClientEInvalid(AstakosClientException):
57
    def __init__(self, message):
58
        """Invalid X-Auth-Token"""
59
        super(AstakosClientEInvalid, self).__init__(message, 401)
60

  
61

  
62
class AstakosClientEMethod(AstakosClientException):
63
    def __init__(self, message):
64
        """Method not allowed"""
65
        super(AstakosClientEMethod, self).__init__(message, 400)
66

  
67

  
68
class AstakosClientENotFound(AstakosClientException):
69
    def __init__(self, message):
70
        """404 Not Found"""
71
        super(AstakosClientENotFound, self).__init__(message, 404)
72

  
73

  
56 74
# --------------------------------------------------------------------
57 75
# Astakos Client Class
58 76

  
......
182 200

  
183 201
        # Return
184 202
        self.logger.debug("Request returned with status %s" % status)
203
        if status == 400:
204
            raise AstakosClientEMethod(data)
205
        if status == 401:
206
            raise AstakosClientEInvalid(data)
207
        if status == 404:
208
            raise AstakosClientENotFound(data)
185 209
        if status < 200 or status >= 300:
186 210
            raise AstakosClientException(data, status)
187 211
        return simplejson.loads(unicode(data))

Also available in: Unified diff