Merge pull request 'fix: catch aiohttp.ClientError in all API call functions (#29)' (#57) from ai/paper-dynasty-discord-29 into next-release
Some checks failed
Build Docker Image / build (push) Has been cancelled
Some checks failed
Build Docker Image / build (push) Has been cancelled
Reviewed-on: #57
This commit is contained in:
commit
3131adaf76
15
api_calls.py
15
api_calls.py
@ -126,6 +126,9 @@ async def db_get(
|
||||
f"Connection timeout to host {req_url} after {retries} attempts"
|
||||
)
|
||||
raise APITimeoutError(f"Connection timeout to host {req_url}")
|
||||
except aiohttp.ClientError as e:
|
||||
logger.error(f"Connection error on GET {req_url}: {e}")
|
||||
raise DatabaseError(f"Connection error: {e}")
|
||||
|
||||
|
||||
async def db_patch(
|
||||
@ -166,6 +169,9 @@ async def db_patch(
|
||||
except asyncio.TimeoutError:
|
||||
logger.error(f"Connection timeout to host {req_url}")
|
||||
raise APITimeoutError(f"Connection timeout to host {req_url}")
|
||||
except aiohttp.ClientError as e:
|
||||
logger.error(f"Connection error on PATCH {req_url}: {e}")
|
||||
raise DatabaseError(f"Connection error: {e}")
|
||||
|
||||
|
||||
async def db_post(
|
||||
@ -205,6 +211,9 @@ async def db_post(
|
||||
except asyncio.TimeoutError:
|
||||
logger.error(f"Connection timeout to host {req_url}")
|
||||
raise APITimeoutError(f"Connection timeout to host {req_url}")
|
||||
except aiohttp.ClientError as e:
|
||||
logger.error(f"Connection error on POST {req_url}: {e}")
|
||||
raise DatabaseError(f"Connection error: {e}")
|
||||
|
||||
|
||||
async def db_put(
|
||||
@ -244,6 +253,9 @@ async def db_put(
|
||||
except asyncio.TimeoutError:
|
||||
logger.error(f"Connection timeout to host {req_url}")
|
||||
raise APITimeoutError(f"Connection timeout to host {req_url}")
|
||||
except aiohttp.ClientError as e:
|
||||
logger.error(f"Connection error on PUT {req_url}: {e}")
|
||||
raise DatabaseError(f"Connection error: {e}")
|
||||
|
||||
|
||||
async def db_delete(endpoint: str, object_id: int, api_ver: int = 2, timeout: int = 5):
|
||||
@ -281,6 +293,9 @@ async def db_delete(endpoint: str, object_id: int, api_ver: int = 2, timeout: in
|
||||
except asyncio.TimeoutError:
|
||||
logger.error(f"Connection timeout to host {req_url}")
|
||||
raise APITimeoutError(f"Connection timeout to host {req_url}")
|
||||
except aiohttp.ClientError as e:
|
||||
logger.error(f"Connection error on DELETE {req_url}: {e}")
|
||||
raise DatabaseError(f"Connection error: {e}")
|
||||
|
||||
|
||||
async def get_team_by_abbrev(abbrev: str):
|
||||
|
||||
Loading…
Reference in New Issue
Block a user