forked from ProtonMail/proton-python-client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexceptions.py
46 lines (30 loc) · 1 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
class ProtonError(Exception):
def __init__(self, message, additional_context=None):
self.message = message
self.additional_context = additional_context
super().__init__(self.message)
class NetworkError(ProtonError):
"""NetworkError"""
class TLSPinningError(ProtonError):
"""TLS Pinning exception"""
class ProtonAPIError(ProtonError):
def __init__(self, ret):
try:
self.code = ret['Code']
self.error = ret['Error']
except: # noqa
self.code = "N/A"
self.error = "N/A"
try:
self.headers = ret["Headers"]
except: # noqa
self.headers = "N/A"
super().__init__(self.error)
class NewConnectionError(ProtonError):
"""Network Error"""
class ConnectionTimeOutError(ProtonError):
"""Connection Time Out Error"""
class UnknownConnectionError(ProtonError):
"""UnknownConnectionError"""
class MissingDepedencyError(ProtonError):
"""Missing dependency error"""