diff --git a/aioqsw/exceptions.py b/aioqsw/exceptions.py index a58eac5..3f90579 100644 --- a/aioqsw/exceptions.py +++ b/aioqsw/exceptions.py @@ -10,6 +10,10 @@ class APIError(QswError): """Exception raised when API fails.""" +class APITimeout(QswError): + """Exception raised when API timeouts.""" + + class InternalServerError(APIError): """Exception raised when API returns internal server error.""" diff --git a/aioqsw/localapi.py b/aioqsw/localapi.py index f08f1cb..f8c5594 100644 --- a/aioqsw/localapi.py +++ b/aioqsw/localapi.py @@ -53,6 +53,7 @@ ) from .exceptions import ( APIError, + APITimeout, InternalServerError, InvalidHost, InvalidResponse, @@ -117,6 +118,8 @@ async def http_request_bytes( ) except ClientError as err: raise InvalidHost(err) from err + except asyncio.TimeoutError as err: + raise APITimeout(err) from err resp_bytes = await resp.read() @@ -144,6 +147,8 @@ async def http_request( ) except ClientError as err: raise InvalidHost(err) from err + except asyncio.TimeoutError as err: + raise APITimeout(err) from err resp_json = None try: