88
99import aiohttp
1010
11- from .exceptions import ConnectionFailedError , DataMissingError
11+ from .exceptions import (
12+ ConnectionAuthenticationError ,
13+ ConnectionError ,
14+ ConnectionSetupError ,
15+ DataMissingError ,
16+ )
1217
1318logger = logging .getLogger (__name__ )
1419
@@ -93,7 +98,7 @@ async def login(self) -> bool:
9398 ) as response :
9499 if not response .cookies :
95100 logger .exception ("Empty cookies after login, bailing out." )
96- raise DataMissingError from None
101+ raise ConnectionSetupError from None
97102 else :
98103 for _ , morsel in response .cookies .items ():
99104 # If the AIROS_ cookie was parsed but isn't automatically added to the jar, add it manually
@@ -146,15 +151,15 @@ async def login(self) -> bool:
146151 logger .exception (
147152 "COOKIE JAR IS EMPTY after login POST. This is a major issue."
148153 )
149- raise DataMissingError from None
154+ raise ConnectionSetupError from None
150155 for cookie in self .session .cookie_jar :
151156 if cookie .key .startswith ("AIROS_" ):
152157 airos_cookie_found = True
153158 if cookie .key == "ok" :
154159 ok_cookie_found = True
155160
156161 if not airos_cookie_found and not ok_cookie_found :
157- raise DataMissingError from None
162+ raise ConnectionSetupError from None
158163
159164 response_text = await response .text ()
160165
@@ -170,16 +175,16 @@ async def login(self) -> bool:
170175 else :
171176 log = f"Login failed with status { response .status } . Full Response: { response .text } "
172177 logger .error (log )
173- raise ConnectionFailedError from None
178+ raise ConnectionAuthenticationError from None
174179 except aiohttp .ClientError as err :
175180 logger .exception ("Error during login" )
176- raise ConnectionFailedError from err
181+ raise ConnectionError from err
177182
178183 async def status (self ) -> dict :
179184 """Retrieve status from the device."""
180185 if not self .connected :
181186 logger .error ("Not connected, login first" )
182- raise ConnectionFailedError from None
187+ raise ConnectionError from None
183188
184189 # --- Step 2: Verify authenticated access by fetching status.cgi ---
185190 authenticated_get_headers = {** self ._common_headers }
@@ -205,4 +210,4 @@ async def status(self) -> dict:
205210 logger .error (log )
206211 except aiohttp .ClientError as err :
207212 logger .exception ("Error during authenticated status.cgi call" )
208- raise ConnectionFailedError from err
213+ raise ConnectionError from err
0 commit comments