From e47f6fe385390349b172345a3d3d12212e38acaf Mon Sep 17 00:00:00 2001 From: Guy Korland Date: Tue, 13 Feb 2024 11:10:40 +0200 Subject: [PATCH] handle connection error --- .../langchain_community/graphs/falkordb_graph.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/libs/community/langchain_community/graphs/falkordb_graph.py b/libs/community/langchain_community/graphs/falkordb_graph.py index ec6663e1a9761..2777d371abfb2 100644 --- a/libs/community/langchain_community/graphs/falkordb_graph.py +++ b/libs/community/langchain_community/graphs/falkordb_graph.py @@ -65,9 +65,13 @@ def __init__( "Please install it with `pip install falkordb`." ) - self._driver = FalkorDB( - host=host, port=port, username=username, password=password, ssl=ssl - ) + try: + self._driver = FalkorDB( + host=host, port=port, username=username, password=password, ssl=ssl + ) + except Exception as e: + raise ConnectionError(f"Failed to connect to FalkorDB: {e}") + self._graph = self._driver.select_graph(database) self.schema: str = "" self.structured_schema: Dict[str, Any] = {}