File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -51,13 +51,17 @@ async def get_data(self):
5151 response = await self ._session .get (url , auth = auth )
5252
5353 _LOGGER .debug ("Response from Glances API: %s" , response .status )
54+ response .raise_for_status ()
5455 print (response .status )
5556 print (response .text )
5657 self .data = await response .json ()
5758 _LOGGER .debug (self .data )
58- except (asyncio .TimeoutError , aiohttp .ClientError ):
59+ except aiohttp .ClientResponseError as err :
60+ _LOGGER .error (err .message )
61+ raise exceptions .GlancesApiAuthorizationError from err
62+ except (asyncio .TimeoutError , aiohttp .ClientError ) as err :
5963 _LOGGER .error ("Can not load data from Glances API" )
60- raise exceptions .GlancesApiConnectionError ()
64+ raise exceptions .GlancesApiConnectionError
6165
6266 async def get_metrics (self , element ):
6367 """Get all the metrics for a monitored element."""
Original file line number Diff line number Diff line change @@ -6,12 +6,14 @@ class GlancesApiError(Exception):
66
77 pass
88
9-
109class GlancesApiConnectionError (GlancesApiError ):
1110 """When a connection error is encountered."""
1211
1312 pass
13+ class GlancesApiAuthorizationError (GlancesApiError ):
14+ """When a connection error is encountered."""
1415
16+ pass
1517
1618class GlancesApiNoDataAvailable (GlancesApiError ):
1719 """When no data is available."""
You can’t perform that action at this time.
0 commit comments