root / astakosclient / astakosclient / errors.py @ 21190887
History | View | Annotate | Download (2.6 kB)
1 | f93cc364 | Ilias Tsitsimpis | # Copyright (C) 2012, 2013 GRNET S.A. All rights reserved.
|
---|---|---|---|
2 | f93cc364 | Ilias Tsitsimpis | #
|
3 | f93cc364 | Ilias Tsitsimpis | # Redistribution and use in source and binary forms, with or
|
4 | f93cc364 | Ilias Tsitsimpis | # without modification, are permitted provided that the following
|
5 | f93cc364 | Ilias Tsitsimpis | # conditions are met:
|
6 | f93cc364 | Ilias Tsitsimpis | #
|
7 | f93cc364 | Ilias Tsitsimpis | # 1. Redistributions of source code must retain the above
|
8 | f93cc364 | Ilias Tsitsimpis | # copyright notice, this list of conditions and the following
|
9 | f93cc364 | Ilias Tsitsimpis | # disclaimer.
|
10 | f93cc364 | Ilias Tsitsimpis | #
|
11 | f93cc364 | Ilias Tsitsimpis | # 2. Redistributions in binary form must reproduce the above
|
12 | f93cc364 | Ilias Tsitsimpis | # copyright notice, this list of conditions and the following
|
13 | f93cc364 | Ilias Tsitsimpis | # disclaimer in the documentation and/or other materials
|
14 | f93cc364 | Ilias Tsitsimpis | # provided with the distribution.
|
15 | f93cc364 | Ilias Tsitsimpis | #
|
16 | f93cc364 | Ilias Tsitsimpis | # THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
|
17 | f93cc364 | Ilias Tsitsimpis | # OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
18 | f93cc364 | Ilias Tsitsimpis | # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
19 | f93cc364 | Ilias Tsitsimpis | # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
|
20 | f93cc364 | Ilias Tsitsimpis | # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
21 | f93cc364 | Ilias Tsitsimpis | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
22 | f93cc364 | Ilias Tsitsimpis | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
23 | f93cc364 | Ilias Tsitsimpis | # USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
24 | f93cc364 | Ilias Tsitsimpis | # AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
25 | f93cc364 | Ilias Tsitsimpis | # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
26 | f93cc364 | Ilias Tsitsimpis | # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
27 | f93cc364 | Ilias Tsitsimpis | # POSSIBILITY OF SUCH DAMAGE.
|
28 | f93cc364 | Ilias Tsitsimpis | #
|
29 | f93cc364 | Ilias Tsitsimpis | # The views and conclusions contained in the software and
|
30 | f93cc364 | Ilias Tsitsimpis | # documentation are those of the authors and should not be
|
31 | f93cc364 | Ilias Tsitsimpis | # interpreted as representing official policies, either expressed
|
32 | f93cc364 | Ilias Tsitsimpis | # or implied, of GRNET S.A.
|
33 | f93cc364 | Ilias Tsitsimpis | |
34 | f93cc364 | Ilias Tsitsimpis | |
35 | f93cc364 | Ilias Tsitsimpis | class AstakosClientException(Exception): |
36 | 21190887 | Ilias Tsitsimpis | def __init__(self, message='', details='', status=None): |
37 | f93cc364 | Ilias Tsitsimpis | self.message = message
|
38 | 21190887 | Ilias Tsitsimpis | self.details = details
|
39 | 21190887 | Ilias Tsitsimpis | if not hasattr(self, 'status'): |
40 | 21190887 | Ilias Tsitsimpis | self.status = status
|
41 | 21190887 | Ilias Tsitsimpis | super(AstakosClientException,
|
42 | 21190887 | Ilias Tsitsimpis | self).__init__(self.message, self.details, self.status) |
43 | f93cc364 | Ilias Tsitsimpis | |
44 | f93cc364 | Ilias Tsitsimpis | |
45 | f93cc364 | Ilias Tsitsimpis | class BadRequest(AstakosClientException): |
46 | 21190887 | Ilias Tsitsimpis | status = 400
|
47 | f93cc364 | Ilias Tsitsimpis | |
48 | f93cc364 | Ilias Tsitsimpis | |
49 | f93cc364 | Ilias Tsitsimpis | class Unauthorized(AstakosClientException): |
50 | 21190887 | Ilias Tsitsimpis | status = 401
|
51 | f93cc364 | Ilias Tsitsimpis | |
52 | f93cc364 | Ilias Tsitsimpis | |
53 | f93cc364 | Ilias Tsitsimpis | class Forbidden(AstakosClientException): |
54 | 21190887 | Ilias Tsitsimpis | status = 403
|
55 | f93cc364 | Ilias Tsitsimpis | |
56 | f93cc364 | Ilias Tsitsimpis | |
57 | f93cc364 | Ilias Tsitsimpis | class NotFound(AstakosClientException): |
58 | 21190887 | Ilias Tsitsimpis | status = 404
|
59 | 2377e7c2 | Ilias Tsitsimpis | |
60 | 2377e7c2 | Ilias Tsitsimpis | |
61 | 794c94e6 | Ilias Tsitsimpis | class NoUserName(AstakosClientException): |
62 | 2377e7c2 | Ilias Tsitsimpis | def __init__(self, uuid): |
63 | 2377e7c2 | Ilias Tsitsimpis | """No display name for the given uuid"""
|
64 | 2377e7c2 | Ilias Tsitsimpis | message = "No display name for the given uuid: %s" % uuid
|
65 | 794c94e6 | Ilias Tsitsimpis | super(NoUserName, self).__init__(message) |
66 | 2377e7c2 | Ilias Tsitsimpis | |
67 | 2377e7c2 | Ilias Tsitsimpis | |
68 | 2377e7c2 | Ilias Tsitsimpis | class NoUUID(AstakosClientException): |
69 | 2377e7c2 | Ilias Tsitsimpis | def __init__(self, display_name): |
70 | 2377e7c2 | Ilias Tsitsimpis | """No uuid for the given display name"""
|
71 | 2377e7c2 | Ilias Tsitsimpis | message = "No uuid for the given display name: %s" % display_name
|
72 | 2377e7c2 | Ilias Tsitsimpis | super(NoUUID, self).__init__(message) |