forked from DevilXD/TwitchDropsMiner
-
Notifications
You must be signed in to change notification settings - Fork 1
/
exceptions.py
94 lines (74 loc) · 2.44 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
class MinerException(Exception):
"""
Base exception class for this application.
"""
def __init__(self, *args: object):
if args:
super().__init__(*args)
else:
super().__init__("Unknown miner error")
class ExitRequest(MinerException):
"""
Raised when the application is requested to exit from outside of the main loop.
Intended for internal use only.
"""
def __init__(self):
super().__init__("Application was requested to exit")
class ReloadRequest(MinerException):
"""
Raised when the application is requested to reload entirely, without closing the GUI.
Intended for internal use only.
"""
def __init__(self):
super().__init__("Application was requested to reload entirely")
class RequestException(MinerException):
"""
Raised for cases where a web request doesn't return what we wanted it to.
"""
def __init__(self, *args: object):
if args:
super().__init__(*args)
else:
super().__init__("Unknown error during request")
class RequestInvalid(RequestException):
"""
Raised when a request becomes no longer valid inside its retry loop.
Intended for internal use only.
"""
def __init__(self):
super().__init__("Request became invalid during its retry loop")
class WebsocketClosed(RequestException):
"""
Raised when the websocket connection has been closed.
Attributes:
-----------
received: bool
`True` if the closing was caused by our side receiving a close frame, `False` otherwise.
"""
def __init__(self, *args: object, received: bool = False):
if args:
super().__init__(*args)
else:
super().__init__("Websocket has been closed")
self.received: bool = received
class LoginException(RequestException):
"""
Raised when an exception occurs during login phase.
"""
def __init__(self, *args: object):
if args:
super().__init__(*args)
else:
super().__init__("Unknown error during login")
class CaptchaRequired(LoginException):
"""
The most dreaded thing about automated scripts...
"""
def __init__(self):
super().__init__("Captcha is required")
class GQLException(RequestException):
"""
Raised when a GQL request returns an error response.
"""
def __init__(self, message: str):
super().__init__(message)