Statistics
| Branch: | Tag: | Revision:

root / snf-pithos-app / pithos / api / faults.py @ f4fbb0fa

History | View | Annotate | Download (2.4 kB)

1 2e662088 Antony Chazapis
# Copyright 2011-2012 GRNET S.A. All rights reserved.
2 2715ade4 Sofia Papagiannaki
#
3 5635f9ef Antony Chazapis
# Redistribution and use in source and binary forms, with or
4 5635f9ef Antony Chazapis
# without modification, are permitted provided that the following
5 5635f9ef Antony Chazapis
# conditions are met:
6 2715ade4 Sofia Papagiannaki
#
7 5635f9ef Antony Chazapis
#   1. Redistributions of source code must retain the above
8 5635f9ef Antony Chazapis
#      copyright notice, this list of conditions and the following
9 5635f9ef Antony Chazapis
#      disclaimer.
10 2715ade4 Sofia Papagiannaki
#
11 5635f9ef Antony Chazapis
#   2. Redistributions in binary form must reproduce the above
12 5635f9ef Antony Chazapis
#      copyright notice, this list of conditions and the following
13 5635f9ef Antony Chazapis
#      disclaimer in the documentation and/or other materials
14 5635f9ef Antony Chazapis
#      provided with the distribution.
15 2715ade4 Sofia Papagiannaki
#
16 5635f9ef Antony Chazapis
# THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
17 5635f9ef Antony Chazapis
# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 5635f9ef Antony Chazapis
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19 5635f9ef Antony Chazapis
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
20 5635f9ef Antony Chazapis
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 5635f9ef Antony Chazapis
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 5635f9ef Antony Chazapis
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
23 5635f9ef Antony Chazapis
# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
24 5635f9ef Antony Chazapis
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 5635f9ef Antony Chazapis
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
26 5635f9ef Antony Chazapis
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27 5635f9ef Antony Chazapis
# POSSIBILITY OF SUCH DAMAGE.
28 2715ade4 Sofia Papagiannaki
#
29 5635f9ef Antony Chazapis
# The views and conclusions contained in the software and
30 5635f9ef Antony Chazapis
# documentation are those of the authors and should not be
31 5635f9ef Antony Chazapis
# interpreted as representing official policies, either expressed
32 5635f9ef Antony Chazapis
# or implied, of GRNET S.A.
33 5635f9ef Antony Chazapis
34 2715ade4 Sofia Papagiannaki
35 b956618e Antony Chazapis
def camelCase(s):
36 b956618e Antony Chazapis
    return s[0].lower() + s[1:]
37 b956618e Antony Chazapis
38 b956618e Antony Chazapis
39 b956618e Antony Chazapis
class Fault(Exception):
40 b956618e Antony Chazapis
    def __init__(self, message='', details='', name=''):
41 b956618e Antony Chazapis
        Exception.__init__(self, message, details, name)
42 b956618e Antony Chazapis
        self.message = message
43 b956618e Antony Chazapis
        self.details = details
44 b956618e Antony Chazapis
        self.name = name or camelCase(self.__class__.__name__)
45 b956618e Antony Chazapis
46 2715ade4 Sofia Papagiannaki
47 b956618e Antony Chazapis
class NotModified(Fault):
48 b956618e Antony Chazapis
    code = 304
49 b956618e Antony Chazapis
50 2715ade4 Sofia Papagiannaki
51 b956618e Antony Chazapis
class BadRequest(Fault):
52 b956618e Antony Chazapis
    code = 400
53 b956618e Antony Chazapis
54 2715ade4 Sofia Papagiannaki
55 b956618e Antony Chazapis
class Unauthorized(Fault):
56 b956618e Antony Chazapis
    code = 401
57 b956618e Antony Chazapis
58 2715ade4 Sofia Papagiannaki
59 14983b5d Antony Chazapis
class Forbidden(Fault):
60 b956618e Antony Chazapis
    code = 403
61 b956618e Antony Chazapis
62 2715ade4 Sofia Papagiannaki
63 b956618e Antony Chazapis
class ItemNotFound(Fault):
64 b956618e Antony Chazapis
    code = 404
65 b956618e Antony Chazapis
66 2715ade4 Sofia Papagiannaki
67 b956618e Antony Chazapis
class Conflict(Fault):
68 b956618e Antony Chazapis
    code = 409
69 b956618e Antony Chazapis
70 2715ade4 Sofia Papagiannaki
71 b956618e Antony Chazapis
class LengthRequired(Fault):
72 b956618e Antony Chazapis
    code = 411
73 b956618e Antony Chazapis
74 2715ade4 Sofia Papagiannaki
75 b956618e Antony Chazapis
class PreconditionFailed(Fault):
76 b956618e Antony Chazapis
    code = 412
77 b956618e Antony Chazapis
78 2715ade4 Sofia Papagiannaki
79 6d0f82fe Antony Chazapis
class RequestEntityTooLarge(Fault):
80 6d0f82fe Antony Chazapis
    code = 413
81 6d0f82fe Antony Chazapis
82 2715ade4 Sofia Papagiannaki
83 b956618e Antony Chazapis
class RangeNotSatisfiable(Fault):
84 b956618e Antony Chazapis
    code = 416
85 b956618e Antony Chazapis
86 2715ade4 Sofia Papagiannaki
87 b956618e Antony Chazapis
class UnprocessableEntity(Fault):
88 b956618e Antony Chazapis
    code = 422
89 b956618e Antony Chazapis
90 2715ade4 Sofia Papagiannaki
91 08de868d Antony Chazapis
class InternalServerError(Fault):
92 08de868d Antony Chazapis
    code = 500
93 08de868d Antony Chazapis
94 2715ade4 Sofia Papagiannaki
95 08de868d Antony Chazapis
class NotImplemented(Fault):
96 08de868d Antony Chazapis
    code = 501