diff --git a/services/core.py b/services/core.py index f1e0ef3..71eb60e 100644 --- a/services/core.py +++ b/services/core.py @@ -10,20 +10,14 @@ headers = {"Content-Type": "application/json"} async def _request_endpoint(query_name, body) -> Any: async with aiohttp.ClientSession() as session: - try: - async with session.post(API_BASE, headers=headers, json=body) as response: - print(f"[services.core] {query_name}: [{response.status}] {len(await response.text())} bytes") - if response.status != 200: - return [] + async with session.post(API_BASE, headers=headers, json=body) as response: + print(f"[services.core] {query_name} response: <{response.status}> {await response.text()}") + if response.status == 200: r = await response.json() if r: return r.get("data", {}).get(query_name, {}) - else: - raise Exception("json response error") - except Exception: - import traceback - - traceback.print_exc() + print(f"[services.core] json response error {r}") + return [] async def get_all_authors() -> List[ChatMember]: @@ -88,4 +82,4 @@ async def get_author(author_id: int = None, slug: str = "", user: str = ""): "variables": None if vars == {} else vars, } - return await _request_endpoint(query_name, gql) + r = await _request_endpoint(query_name, gql)