root / api / faults.py @ 17301566
History | View | Annotate | Download (882 Bytes)
1 |
#
|
---|---|
2 |
# Copyright (c) 2011 Greek Research and Technology Network
|
3 |
#
|
4 |
|
5 |
def camelCase(s): |
6 |
return s[0].lower() + s[1:] |
7 |
|
8 |
|
9 |
class Fault(Exception): |
10 |
def __init__(self, message='', details='', name=''): |
11 |
Exception.__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 NotModified(Fault): |
17 |
code = 304
|
18 |
|
19 |
class BadRequest(Fault): |
20 |
code = 400
|
21 |
|
22 |
class Unauthorized(Fault): |
23 |
code = 401
|
24 |
|
25 |
class ResizeNotAllowed(Fault): |
26 |
code = 403
|
27 |
|
28 |
class ItemNotFound(Fault): |
29 |
code = 404
|
30 |
|
31 |
class LengthRequired(Fault): |
32 |
code = 411
|
33 |
|
34 |
class PreconditionFailed(Fault): |
35 |
code = 412
|
36 |
|
37 |
class RangeNotSatisfiable(Fault): |
38 |
code = 416
|
39 |
|
40 |
class UnprocessableEntity(Fault): |
41 |
code = 422
|
42 |
|
43 |
class ServiceUnavailable(Fault): |
44 |
code = 503
|