Skip to content

Commit

Permalink
interface: handle asyncio.TimeoutError on aiohttp requests
Browse files Browse the repository at this point in the history
Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
  • Loading branch information
Noltari committed Feb 21, 2024
1 parent 4f06286 commit 3ed2511
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions aemet_opendata/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@ async def api_call(self, cmd: str, fetch_data: bool = False) -> dict[str, Any]:
timeout=API_TIMEOUT,
headers=self.headers,
)
except asyncio.TimeoutError as err:
raise AemetTimeout(err) from err
except ClientError as err:
raise AemetError(err) from err

Expand Down Expand Up @@ -185,6 +187,8 @@ async def api_data(self, url: str) -> dict[str, Any]:
url,
timeout=API_TIMEOUT,
)
except asyncio.TimeoutError as err:
raise AemetTimeout(err) from err
except ClientError as err:
raise AemetError(err) from err

Expand Down

0 comments on commit 3ed2511

Please sign in to comment.