root / snf-astakos-app / astakos / im / api / faults.py @ ff8333db
History | View | Annotate | Download (2 kB)
1 | aba1e498 | Antony Chazapis | # Copyright 2011-2012 GRNET S.A. All rights reserved.
|
---|---|---|---|
2 | 5ce3ce4f | Sofia Papagiannaki | #
|
3 | 64cd4730 | Antony Chazapis | # Redistribution and use in source and binary forms, with or
|
4 | 64cd4730 | Antony Chazapis | # without modification, are permitted provided that the following
|
5 | 64cd4730 | Antony Chazapis | # conditions are met:
|
6 | 5ce3ce4f | Sofia Papagiannaki | #
|
7 | 64cd4730 | Antony Chazapis | # 1. Redistributions of source code must retain the above
|
8 | 64cd4730 | Antony Chazapis | # copyright notice, this list of conditions and the following
|
9 | 64cd4730 | Antony Chazapis | # disclaimer.
|
10 | 5ce3ce4f | Sofia Papagiannaki | #
|
11 | 64cd4730 | Antony Chazapis | # 2. Redistributions in binary form must reproduce the above
|
12 | 64cd4730 | Antony Chazapis | # copyright notice, this list of conditions and the following
|
13 | 64cd4730 | Antony Chazapis | # disclaimer in the documentation and/or other materials
|
14 | 64cd4730 | Antony Chazapis | # provided with the distribution.
|
15 | 5ce3ce4f | Sofia Papagiannaki | #
|
16 | 64cd4730 | Antony Chazapis | # THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
|
17 | 64cd4730 | Antony Chazapis | # OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
18 | 64cd4730 | Antony Chazapis | # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
19 | 64cd4730 | Antony Chazapis | # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
|
20 | 64cd4730 | Antony Chazapis | # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
21 | 64cd4730 | Antony Chazapis | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
22 | 64cd4730 | Antony Chazapis | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
23 | 64cd4730 | Antony Chazapis | # USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
24 | 64cd4730 | Antony Chazapis | # AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
25 | 64cd4730 | Antony Chazapis | # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
26 | 64cd4730 | Antony Chazapis | # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
27 | 64cd4730 | Antony Chazapis | # POSSIBILITY OF SUCH DAMAGE.
|
28 | 5ce3ce4f | Sofia Papagiannaki | #
|
29 | 64cd4730 | Antony Chazapis | # The views and conclusions contained in the software and
|
30 | 64cd4730 | Antony Chazapis | # documentation are those of the authors and should not be
|
31 | 64cd4730 | Antony Chazapis | # interpreted as representing official policies, either expressed
|
32 | 64cd4730 | Antony Chazapis | # or implied, of GRNET S.A.
|
33 | 64cd4730 | Antony Chazapis | |
34 | 5ce3ce4f | Sofia Papagiannaki | |
35 | 64cd4730 | Antony Chazapis | def camelCase(s): |
36 | 64cd4730 | Antony Chazapis | return s[0].lower() + s[1:] |
37 | 64cd4730 | Antony Chazapis | |
38 | 5ce3ce4f | Sofia Papagiannaki | |
39 | 64cd4730 | Antony Chazapis | class Fault(Exception): |
40 | 64cd4730 | Antony Chazapis | def __init__(self, message='', details='', name=''): |
41 | 64cd4730 | Antony Chazapis | Exception.__init__(self, message, details, name) |
42 | 64cd4730 | Antony Chazapis | self.message = message
|
43 | 64cd4730 | Antony Chazapis | self.details = details
|
44 | 64cd4730 | Antony Chazapis | self.name = name or camelCase(self.__class__.__name__) |
45 | 64cd4730 | Antony Chazapis | |
46 | 5ce3ce4f | Sofia Papagiannaki | |
47 | 64cd4730 | Antony Chazapis | class BadRequest(Fault): |
48 | 64cd4730 | Antony Chazapis | code = 400
|
49 | 64cd4730 | Antony Chazapis | |
50 | 5ce3ce4f | Sofia Papagiannaki | |
51 | 64cd4730 | Antony Chazapis | class Unauthorized(Fault): |
52 | 64cd4730 | Antony Chazapis | code = 401
|
53 | 64cd4730 | Antony Chazapis | |
54 | 5ce3ce4f | Sofia Papagiannaki | |
55 | 863193cb | Sofia Papagiannaki | class InternalServerError(Fault): |
56 | 863193cb | Sofia Papagiannaki | code = 500
|
57 | 30dc8c1a | Sofia Papagiannaki | |
58 | 5ce3ce4f | Sofia Papagiannaki | |
59 | 30dc8c1a | Sofia Papagiannaki | class Forbidden(Fault): |
60 | 30dc8c1a | Sofia Papagiannaki | code = 403
|
61 | 30dc8c1a | Sofia Papagiannaki | |
62 | 5ce3ce4f | Sofia Papagiannaki | |
63 | 30dc8c1a | Sofia Papagiannaki | class ItemNotFound(Fault): |
64 | 5ce3ce4f | Sofia Papagiannaki | code = 404 |