Statistics
| Branch: | Tag: | Revision:

root / api / errors.py @ b016b476

History | View | Annotate | Download (609 Bytes)

1 7e2f9d4b Giorgos Verigakis
#
2 7e2f9d4b Giorgos Verigakis
# Copyright (c) 2010 Greek Research and Technology Network
3 7e2f9d4b Giorgos Verigakis
#
4 7e2f9d4b Giorgos Verigakis
5 7e2f9d4b Giorgos Verigakis
def camelCase(s):
6 7e2f9d4b Giorgos Verigakis
    return s[0].lower() + s[1:]
7 7e2f9d4b Giorgos Verigakis
8 7e2f9d4b Giorgos Verigakis
9 7e2f9d4b Giorgos Verigakis
class Fault(BaseException):
10 7e2f9d4b Giorgos Verigakis
    def __init__(self, message='', details='', name=''):
11 7e2f9d4b Giorgos Verigakis
        BaseException.__init__(self, message, details, name)
12 7e2f9d4b Giorgos Verigakis
        self.message = message
13 7e2f9d4b Giorgos Verigakis
        self.details = details
14 7e2f9d4b Giorgos Verigakis
        self.name = name or camelCase(self.__class__.__name__)
15 7e2f9d4b Giorgos Verigakis
16 7e2f9d4b Giorgos Verigakis
class BadRequest(Fault):
17 7e2f9d4b Giorgos Verigakis
    code = 400
18 7e2f9d4b Giorgos Verigakis
19 7e2f9d4b Giorgos Verigakis
class Unauthorized(Fault):
20 7e2f9d4b Giorgos Verigakis
    code = 401
21 7e2f9d4b Giorgos Verigakis
22 b016b476 Giorgos Verigakis
class ResizeNotAllowed(Fault):
23 b016b476 Giorgos Verigakis
    code = 403
24 b016b476 Giorgos Verigakis
25 7e2f9d4b Giorgos Verigakis
class ItemNotFound(Fault):
26 7e2f9d4b Giorgos Verigakis
    code = 404
27 7e2f9d4b Giorgos Verigakis
28 c36934a7 Giorgos Verigakis
class ServiceUnavailable(Fault):
29 c36934a7 Giorgos Verigakis
    code = 503