exceptions.py 1.81 KB
Newer Older
Michal Simon's avatar
Michal Simon committed
1
#   Copyright notice:
Michal Simon's avatar
Michal Simon committed
2
#   Copyright  Members of the EMI Collaboration, 2010.
Michal Simon's avatar
Michal Simon committed
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# 
#   See www.eu-emi.eu for details on the copyright holders
# 
#   Licensed under the Apache License, Version 2.0 (the "License");
#   you may not use this file except in compliance with the License.
#   You may obtain a copy of the License at
# 
#       http://www.apache.org/licenses/LICENSE-2.0
# 
#   Unless required by applicable law or agreed to in writing, software
#   distributed under the License is distributed on an "AS IS" BASIS,
#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#   See the License for the specific language governing permissions and
#   limitations under the License.
ayllon's avatar
ayllon committed
17

ayllon's avatar
ayllon committed
18
19
class FTS3ClientException(Exception):
    pass
ayllon's avatar
ayllon committed
20
21
22


class BadEndpoint(FTS3ClientException):
23
24
    def __init__(self, reason):
        self.reason = reason
ayllon's avatar
ayllon committed
25

ayllon's avatar
ayllon committed
26
    def __str__(self):
27
        return "Bad endpoint: %s" % self.reason
ayllon's avatar
ayllon committed
28
29
30


class Unauthorized(FTS3ClientException):
ayllon's avatar
ayllon committed
31
32
    def __str__(self):
        return "Unauthorized"
ayllon's avatar
ayllon committed
33
34
35


class ClientError(FTS3ClientException):
ayllon's avatar
ayllon committed
36
37
    def __init__(self, reason):
        self.reason = reason
ayllon's avatar
ayllon committed
38

ayllon's avatar
ayllon committed
39
40
    def __str__(self):
        return "Client error: %s" % self.reason
ayllon's avatar
ayllon committed
41
42


43
44
45
46
47
48
49
50
51
52
class NeedDelegation(ClientError):
    def __str__(self):
        return "Need to delegate credentials"


class FailedDependency(ClientError):
    def __str__(self):
        return "Failed dependency"


ayllon's avatar
ayllon committed
53
class ServerError(FTS3ClientException):
ayllon's avatar
ayllon committed
54
55
56
57
58
    def __init__(self, reason):
        self.reason = reason

    def __str__(self):
        return "Server error: %s" % self.reason
ayllon's avatar
ayllon committed
59
60


61
62
63
64
65
class TryAgain(ServerError):
    def __str__(self):
        return "Try again: %s" % self.reason


ayllon's avatar
ayllon committed
66
class NotFound(FTS3ClientException):
ayllon's avatar
ayllon committed
67
68
69
70
71
    def __init__(self, resource):
        self.resource = resource

    def __str__(self):
        return "Not found: %s" % self.resource