Statistics
| Branch: | Tag: | Revision:

root / api / errors.py @ b016b476

History | View | Annotate | Download (609 Bytes)

1
#
2
# Copyright (c) 2010 Greek Research and Technology Network
3
#
4

    
5
def camelCase(s):
6
    return s[0].lower() + s[1:]
7

    
8

    
9
class Fault(BaseException):
10
    def __init__(self, message='', details='', name=''):
11
        BaseException.__init__(self, message, details, name)
12
        self.message = message
13
        self.details = details
14
        self.name = name or camelCase(self.__class__.__name__)
15

    
16
class BadRequest(Fault):
17
    code = 400
18

    
19
class Unauthorized(Fault):
20
    code = 401
21

    
22
class ResizeNotAllowed(Fault):
23
    code = 403
24

    
25
class ItemNotFound(Fault):
26
    code = 404
27

    
28
class ServiceUnavailable(Fault):
29
    code = 503