From 7e4b676d534b2a63a00706d7fcb6cef204f289f2 Mon Sep 17 00:00:00 2001 From: Tomaz Bratanic Date: Thu, 8 Feb 2024 04:16:14 +0100 Subject: [PATCH] community[patch]: Better error propagation for neo4jgraph (#17190) There are other errors that could happen when refreshing the schema, so we want to propagate specific errors for more clarity --- .../langchain_community/graphs/neo4j_graph.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/libs/community/langchain_community/graphs/neo4j_graph.py b/libs/community/langchain_community/graphs/neo4j_graph.py index 125fd96b15..9df427e38c 100644 --- a/libs/community/langchain_community/graphs/neo4j_graph.py +++ b/libs/community/langchain_community/graphs/neo4j_graph.py @@ -133,12 +133,14 @@ class Neo4jGraph(GraphStore): # Set schema try: self.refresh_schema() - except neo4j.exceptions.ClientError: - raise ValueError( - "Could not use APOC procedures. " - "Please ensure the APOC plugin is installed in Neo4j and that " - "'apoc.meta.data()' is allowed in Neo4j configuration " - ) + except neo4j.exceptions.ClientError as e: + if e.code == "Neo.ClientError.Procedure.ProcedureNotFound": + raise ValueError( + "Could not use APOC procedures. " + "Please ensure the APOC plugin is installed in Neo4j and that " + "'apoc.meta.data()' is allowed in Neo4j configuration " + ) + raise e @property def get_schema(self) -> str: