forked from activeloopai/deeplake
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexceptions.py
152 lines (93 loc) · 3.81 KB
/
exceptions.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
from click import ClickException
class OutOfBoundsError(Exception):
"""Raised upon finding a missing chunk."""
pass
class AlignmentError(Exception):
"""Raised when there is an Alignment error."""
pass
class IncompatibleShapes(Exception):
"""Shapes do not match"""
pass
class IncompatibleBroadcasting(Exception):
"""Broadcasting issue"""
pass
class IncompatibleTypes(Exception):
"""Types can not cast"""
pass
class WrongTypeError(Exception):
"""Types is not supported"""
pass
class NotAuthorized(Exception):
"""Types is not supported"""
pass
class NotFound(Exception):
"""When Info could not be found for array"""
pass
class FileSystemException(Exception):
"""Error working with local file system"""
pass
class S3Exception(Exception):
"""Error working with AWS"""
pass
class S3CredsParseException(Exception):
"""Can't parse AWS creds"""
pass
class HubException(ClickException):
def __init__(self, message=None, code=None):
super(HubException, self).__init__(message)
class AuthenticationException(HubException):
def __init__(self, message="Authentication failed. Please login again."):
super(AuthenticationException, self).__init__(message=message)
class AuthorizationException(HubException):
def __init__(self, response):
try:
message = response.json()["message"]
except (KeyError, AttributeError):
message = "You are not authorized to access this resource on Snark AI."
super(AuthorizationException, self).__init__(message=message)
class NotFoundException(HubException):
def __init__(
self,
message="The resource you are looking for was not found. Check if the name or id is correct.",
):
super(NotFoundException, self).__init__(message=message)
class BadRequestException(HubException):
def __init__(self, response):
try:
message = "One or more request parameters is incorrect\n%s" % str(
response.json()["message"]
)
except (KeyError, AttributeError):
message = "One or more request parameters is incorrect, %s" % str(
response.content
)
super(BadRequestException, self).__init__(message=message)
class OverLimitException(HubException):
def __init__(
self,
message="You are over the allowed limits for this operation. Consider upgrading your account.",
):
super(OverLimitException, self).__init__(message=message)
class ServerException(HubException):
def __init__(self, message="Internal Snark AI server error."):
super(ServerException, self).__init__(message=message)
class BadGatewayException(HubException):
def __init__(self, message="Invalid response from Snark AI server."):
super(BadGatewayException, self).__init__(message=message)
class GatewayTimeoutException(HubException):
def __init__(self, message="Snark AI server took too long to respond."):
super(GatewayTimeoutException, self).__init__(message=message)
class WaitTimeoutException(HubException):
def __init__(self, message="Timeout waiting for server state update."):
super(WaitTimeoutException, self).__init__(message=message)
class LockedException(HubException):
def __init__(self, message="Resource locked."):
super(LockedException, self).__init__(message=message)
class DatasetNotFound(HubException):
def __init__(self, response):
message = f"The dataset with tag {response} was not found"
super(DatasetNotFound, self).__init__(message=message)
class PermissionException(HubException):
def __init__(self, response):
message = f"No permision to store the dataset at {response}"
super(PermissionException, self).__init__(message=message)