root / snf-astakos-client / astakosclient / errors.py @ 2377e7c2
History | View | Annotate | Download (2.8 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 | f93cc364 | Ilias Tsitsimpis | def __init__(self, message, status=0): |
37 | f93cc364 | Ilias Tsitsimpis | self.message = message
|
38 | f93cc364 | Ilias Tsitsimpis | self.status = status
|
39 | f93cc364 | Ilias Tsitsimpis | |
40 | f93cc364 | Ilias Tsitsimpis | def __str__(self): |
41 | f93cc364 | Ilias Tsitsimpis | return repr(self.message) |
42 | f93cc364 | Ilias Tsitsimpis | |
43 | f93cc364 | Ilias Tsitsimpis | |
44 | f93cc364 | Ilias Tsitsimpis | class BadRequest(AstakosClientException): |
45 | f93cc364 | Ilias Tsitsimpis | def __init__(self, message): |
46 | f93cc364 | Ilias Tsitsimpis | """400 Bad Request"""
|
47 | f93cc364 | Ilias Tsitsimpis | super(BadRequest, self).__init__(message, 400) |
48 | f93cc364 | Ilias Tsitsimpis | |
49 | f93cc364 | Ilias Tsitsimpis | |
50 | f93cc364 | Ilias Tsitsimpis | class Unauthorized(AstakosClientException): |
51 | f93cc364 | Ilias Tsitsimpis | def __init__(self, message): |
52 | f93cc364 | Ilias Tsitsimpis | """401 Invalid X-Auth-Token"""
|
53 | f93cc364 | Ilias Tsitsimpis | super(Unauthorized, self).__init__(message, 401) |
54 | f93cc364 | Ilias Tsitsimpis | |
55 | f93cc364 | Ilias Tsitsimpis | |
56 | f93cc364 | Ilias Tsitsimpis | class Forbidden(AstakosClientException): |
57 | f93cc364 | Ilias Tsitsimpis | def __init__(self, message): |
58 | f93cc364 | Ilias Tsitsimpis | """403 Forbidden"""
|
59 | f93cc364 | Ilias Tsitsimpis | super(Forbidden, self).__init__(message, 403) |
60 | f93cc364 | Ilias Tsitsimpis | |
61 | f93cc364 | Ilias Tsitsimpis | |
62 | f93cc364 | Ilias Tsitsimpis | class NotFound(AstakosClientException): |
63 | f93cc364 | Ilias Tsitsimpis | def __init__(self, message): |
64 | f93cc364 | Ilias Tsitsimpis | """404 Not Found"""
|
65 | f93cc364 | Ilias Tsitsimpis | super(NotFound, self).__init__(message, 404) |
66 | 2377e7c2 | Ilias Tsitsimpis | |
67 | 2377e7c2 | Ilias Tsitsimpis | |
68 | 2377e7c2 | Ilias Tsitsimpis | class NoDisplayName(AstakosClientException): |
69 | 2377e7c2 | Ilias Tsitsimpis | def __init__(self, uuid): |
70 | 2377e7c2 | Ilias Tsitsimpis | """No display name for the given uuid"""
|
71 | 2377e7c2 | Ilias Tsitsimpis | message = "No display name for the given uuid: %s" % uuid
|
72 | 2377e7c2 | Ilias Tsitsimpis | super(NoDisplayName, self).__init__(message) |
73 | 2377e7c2 | Ilias Tsitsimpis | |
74 | 2377e7c2 | Ilias Tsitsimpis | |
75 | 2377e7c2 | Ilias Tsitsimpis | class NoUUID(AstakosClientException): |
76 | 2377e7c2 | Ilias Tsitsimpis | def __init__(self, display_name): |
77 | 2377e7c2 | Ilias Tsitsimpis | """No uuid for the given display name"""
|
78 | 2377e7c2 | Ilias Tsitsimpis | message = "No uuid for the given display name: %s" % display_name
|
79 | 2377e7c2 | Ilias Tsitsimpis | super(NoUUID, self).__init__(message) |