Statistics
| Branch: | Tag: | Revision:

root / src / pithos / api / faults.py @ c7e0bbe2

History | View | Annotate | Download (650 Bytes)

1 c7e0bbe2 Antony Chazapis
# vim: ts=4 sts=4 et ai sw=4 fileencoding=utf-8
2 c7e0bbe2 Antony Chazapis
#
3 c7e0bbe2 Antony Chazapis
# Copyright (c) 2011 Greek Research and Technology Network
4 c7e0bbe2 Antony Chazapis
#
5 c7e0bbe2 Antony Chazapis
6 c7e0bbe2 Antony Chazapis
def camelCase(s):
7 c7e0bbe2 Antony Chazapis
    return s[0].lower() + s[1:]
8 c7e0bbe2 Antony Chazapis
9 c7e0bbe2 Antony Chazapis
10 c7e0bbe2 Antony Chazapis
class Fault(Exception):
11 c7e0bbe2 Antony Chazapis
    def __init__(self, message='', details='', name=''):
12 c7e0bbe2 Antony Chazapis
        Exception.__init__(self, message, details, name)
13 c7e0bbe2 Antony Chazapis
        self.message = message
14 c7e0bbe2 Antony Chazapis
        self.details = details
15 c7e0bbe2 Antony Chazapis
        self.name = name or camelCase(self.__class__.__name__)
16 c7e0bbe2 Antony Chazapis
17 c7e0bbe2 Antony Chazapis
class BadRequest(Fault):
18 c7e0bbe2 Antony Chazapis
    code = 400
19 c7e0bbe2 Antony Chazapis
20 c7e0bbe2 Antony Chazapis
class Unauthorized(Fault):
21 c7e0bbe2 Antony Chazapis
    code = 401
22 c7e0bbe2 Antony Chazapis
23 c7e0bbe2 Antony Chazapis
class ResizeNotAllowed(Fault):
24 c7e0bbe2 Antony Chazapis
    code = 403
25 c7e0bbe2 Antony Chazapis
26 c7e0bbe2 Antony Chazapis
class ItemNotFound(Fault):
27 c7e0bbe2 Antony Chazapis
    code = 404
28 c7e0bbe2 Antony Chazapis
29 c7e0bbe2 Antony Chazapis
class ServiceUnavailable(Fault):
30 c7e0bbe2 Antony Chazapis
    code = 503