Revision 21190887 astakosclient/astakosclient/errors.py

b/astakosclient/astakosclient/errors.py
33 33

  
34 34

  
35 35
class AstakosClientException(Exception):
36
    def __init__(self, message, status=0):
36
    def __init__(self, message='', details='', status=None):
37 37
        self.message = message
38
        self.status = status
39

  
40
    def __str__(self):
41
        return repr(self.message)
38
        self.details = details
39
        if not hasattr(self, 'status'):
40
            self.status = status
41
        super(AstakosClientException,
42
              self).__init__(self.message, self.details, self.status)
42 43

  
43 44

  
44 45
class BadRequest(AstakosClientException):
45
    def __init__(self, message):
46
        """400 Bad Request"""
47
        super(BadRequest, self).__init__(message, 400)
46
    status = 400
48 47

  
49 48

  
50 49
class Unauthorized(AstakosClientException):
51
    def __init__(self, message):
52
        """401 Invalid X-Auth-Token"""
53
        super(Unauthorized, self).__init__(message, 401)
50
    status = 401
54 51

  
55 52

  
56 53
class Forbidden(AstakosClientException):
57
    def __init__(self, message):
58
        """403 Forbidden"""
59
        super(Forbidden, self).__init__(message, 403)
54
    status = 403
60 55

  
61 56

  
62 57
class NotFound(AstakosClientException):
63
    def __init__(self, message):
64
        """404 Not Found"""
65
        super(NotFound, self).__init__(message, 404)
58
    status = 404
66 59

  
67 60

  
68 61
class NoUserName(AstakosClientException):

Also available in: Unified diff