-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathexceptions.py
More file actions
51 lines (37 loc) · 1.01 KB
/
Copy pathexceptions.py
File metadata and controls
51 lines (37 loc) · 1.01 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
from typing import Optional
from aiohttp import ClientResponse
class APIError(Exception):
"""
Root exception for all module raised errors.
"""
def __init__(self, message: str):
self.message = message
super().__init__(self.message)
class CommunicationError(APIError):
"""
Parent class for exceptions that involve communication
with the ChargePoint API.
"""
def __init__(
self, response: ClientResponse, message: str, body: Optional[dict] = None
):
self.response = response
self.message = message
self.body = body
super().__init__(self.message)
class LoginError(CommunicationError):
"""
Login failed.
"""
class InvalidSession(CommunicationError):
"""
Login expired.
"""
class DatadomeCaptcha(APIError):
"""
Hit datadome captcha.
"""
def __init__(self, captcha: str, message: str):
self.captcha = captcha
self.message = message
super().__init__(self.message)