version 0.34

This commit is contained in:
GOG Galaxy SDK Team
2019-06-14 16:54:11 +02:00
parent e2f26271cb
commit 7789927ed9
2 changed files with 8 additions and 3 deletions

View File

@@ -4,6 +4,7 @@ from http import HTTPStatus
import aiohttp
import certifi
import logging
from galaxy.api.errors import (
AccessDenied, AuthenticationRequired, BackendTimeout, BackendNotAvailable, BackendError, NetworkError,
@@ -21,9 +22,9 @@ class HttpClient:
async def close(self):
await self._session.close()
async def request(self, method, *args, **kwargs):
async def request(self, method, url, *args, **kwargs):
try:
response = await self._session.request(method, *args, **kwargs)
response = await self._session.request(method, url, *args, **kwargs)
except asyncio.TimeoutError:
raise BackendTimeout()
except aiohttp.ServerDisconnectedError:
@@ -33,6 +34,8 @@ class HttpClient:
except aiohttp.ContentTypeError:
raise UnknownBackendResponse()
except aiohttp.ClientError:
logging.exception(
"Caught exception while running {} request for {}".format(method, url))
raise UnknownError()
if response.status == HTTPStatus.UNAUTHORIZED:
raise AuthenticationRequired()
@@ -45,6 +48,8 @@ class HttpClient:
if response.status >= 500:
raise BackendError()
if response.status >= 400:
logging.warning(
"Got status {} while running {} request for {}".format(response.status, method, url))
raise UnknownError()
return response