Repository navigation
Expand file tree
/
Copy pathexceptions.py
More file actions
65 lines (36 loc) · 1.51 KB
/
Copy pathexceptions.py
File metadata and controls
65 lines (36 loc) · 1.51 KB
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
from datetime import datetime
class InvalidShardError(Exception):
pass
class InvalidFilterError(Exception):
pass
class RequiredFilterError(Exception):
pass
class APIError(Exception):
def __init__(self, message='Something went wrong with your request',
*args, **kwargs):
super().__init__(message)
class ResponseError(APIError):
pass
class UnauthorizedError(APIError):
def __init__(self, *args, **kwargs):
super().__init__('API key invalid or missing')
class NotFoundError(APIError):
def __init__(self, *args, **kwargs):
super().__init__('The specified resource was not found')
class InvalidContentTypeError(APIError):
def __init__(self, *args, **kwargs):
super().__init__('Unsupported media type')
class RateLimitError(APIError):
def __init__(self, *args, **kwargs):
self.response_headers = kwargs.pop('response_headers', None)
self.rl_limit = int(self.response_headers.get('X-Ratelimit-Limit'))
self.rl_reset = datetime.fromtimestamp(
int(self.response_headers.get('X-Ratelimit-Reset')))
super().__init__('Too many requests. Limit: {} Reset: {}'.format(
self.rl_limit, self.rl_reset))
class OldTelemetryError(APIError):
def __init__(self, *args, **kwargs):
super().__init__('Telemetry was not found or no longer available')
class TelemetryURLError(APIError):
def __init__(self, *args, **kwargs):
super().__init__('Telemetry host differs from official')