Skip to content

Commit

Permalink
catching more errors and logging error even if returning in json
Browse files Browse the repository at this point in the history
  • Loading branch information
EvanDietzMorris committed Aug 16, 2024
1 parent b2e653f commit e50f6a9
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions PLATER/services/util/graph_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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}'}]}
Expand Down

0 comments on commit e50f6a9

Please sign in to comment.