-
Notifications
You must be signed in to change notification settings - Fork 3
/
sc_exceptions.py
80 lines (55 loc) · 2.22 KB
/
sc_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
class SCError(Exception):
pass
class EntityTooLarge(SCError):
"""Raised when submitted file is too large"""
def __str__(self):
return "The submitted file was too large (max 15MB)"
class InvalidDCAppLink(SCError):
"""Raised when an invalid Dreamcatcher app link is submitted"""
def __str__(self):
return "Invalid Dreamcatcher app url"
class FullSizeDCAppImage(SCError):
"""Raised when a direct link to a Dreamcatcher app image is already full size"""
def __str__(self):
return "Invalid Dreamcatcher app url, or the image is already full size"
class NoMatchesFound(SCError):
"""Raised when no matching images are found"""
def __str__(self):
return "No matches found. Possible reasons:"
def reasons(self):
reasons = [
"The image was heavily altered or cropped",
"Twitter is not the source of this image",
"Sourcecatcher is not following the source Twitter user",
]
return reasons
class InvalidLink(SCError):
"""Raised when an invalid link is used"""
def __str__(self):
return "Could not find any data at this link"
class InvalidImage(SCError):
"""Raised when an image cannot be opened"""
def __str__(self):
return "Could not open image (is it actually an image?)"
class DCAppError(SCError):
def __init__(self, reason):
self.reason = reason
def __str__(self):
return f"Could not connect to DC app website ({self.reason})"
class TWError(SCError):
def __init__(self, message, user=None, tweet_id=None):
self.message = message
self.link = None
if user is not None and tweet_id is not None:
self.link = f"https://twitter.com/{user}/status/{tweet_id}"
def __str__(self):
return f"A matching image was found but the tweet no longer exists ({self.message})"
class TWRateError(SCError):
def __str__(self):
return "Sourcecatcher reached the Twitter API rate limit, try again later"
class VideoDownloadError(SCError):
def __str__():
return "Could not download file"
class AnimatedGIFError(SCError):
def __str__(self):
return "Searching animated GIFs is not supported"