Skip to content

Commit

Permalink
Remove aiohttp ClientError
Browse files Browse the repository at this point in the history
  • Loading branch information
bieniu committed Mar 23, 2020
1 parent 849dd22 commit dc2d63e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 12 deletions.
16 changes: 5 additions & 11 deletions gios/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
"""
import logging

from aiohttp import ClientError

_LOGGER = logging.getLogger(__name__)

ATTR_AQI = "AQI"
Expand Down Expand Up @@ -142,15 +140,11 @@ async def _get_indexes(self):
async def _async_get(self, url):
"""Retreive data from GIOS API."""
data = None
try:
async with self.session.get(url) as resp:
if resp.status != HTTP_OK:
_LOGGER.warning("Invalid response from GIOS API: %s", resp.status)
raise ApiError(resp.status)
data = await resp.json()
except ClientError as error:
_LOGGER.error("Invalid response from from GIOS API: %s", error)
return
async with self.session.get(url) as resp:
if resp.status != HTTP_OK:
_LOGGER.warning("Invalid response from GIOS API: %s", resp.status)
raise ApiError(resp.status)
data = await resp.json()
_LOGGER.debug("Data retrieved from %s, status: %s", url, resp.status)
return data

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

setup(
name="gios",
version="0.0.5",
version="0.0.6",
author="Maciej Bieniek",
author_email="[email protected]",
description="Python wrapper for getting air quality data from GIOŚ servers.",
Expand Down

0 comments on commit dc2d63e

Please sign in to comment.