From e50f6a9cdd64e04e779216e0d5c89eaa70a3f1fa Mon Sep 17 00:00:00 2001 From: Evan Morris Date: Fri, 16 Aug 2024 15:22:44 -0400 Subject: [PATCH] catching more errors and logging error even if returning in json --- PLATER/services/util/graph_adapter.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/PLATER/services/util/graph_adapter.py b/PLATER/services/util/graph_adapter.py index ea813e7..a640f55 100644 --- a/PLATER/services/util/graph_adapter.py +++ b/PLATER/services/util/graph_adapter.py @@ -99,18 +99,19 @@ async def run(self, convert_to_dict=convert_to_dict, convert_to_trapi=convert_to_trapi, qgraph=qgraph) - except neo4j.exceptions.ClientError as e: + except neo4j.exceptions.Neo4jError as e: if return_errors: + logger.error(e) return {"results": [], "errors": [{"code": e.code, "message": e.message}]} raise e except (neo4j.exceptions.DriverError, neo4j.exceptions.ServiceUnavailable) as e: if return_errors: + logger.error(e) return {"results": [], "errors": [{"code": "", "message": f'A driver error occurred: {e}'}]} - raise e return run_async_result def run_sync(self, @@ -124,14 +125,16 @@ def run_sync(self, query, query_parameters=query_parameters, convert_to_dict=convert_to_dict) - except neo4j.exceptions.ClientError as e: + except neo4j.exceptions.Neo4jError as e: if return_errors: + logger.error(e) return {"results": [], "errors": [{"code": e.code, "message": e.message}]} raise e except (neo4j.exceptions.DriverError, neo4j.exceptions.ServiceUnavailable) as e: if return_errors: + logger.error(e) return {"results": [], "errors": [{"code": "", "message": f'A driver error occurred: {e}'}]}