From 08c7bb523097e613dbc84e0d9278e25701f6a915 Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Thu, 29 Jun 2023 18:38:36 -0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix(loading.py):=20catch=20addit?= =?UTF-8?q?ional=20exception=20when=20object=20has=20no=20'conn'=20field?= =?UTF-8?q?=20to=20improve=20error=20handling=20The=20code=20now=20catches?= =?UTF-8?q?=20an=20additional=20exception=20when=20the=20object=20does=20n?= =?UTF-8?q?ot=20have=20a=20'conn'=20field.=20This=20improves=20the=20error?= =?UTF-8?q?=20handling=20by=20providing=20a=20more=20specific=20error=20me?= =?UTF-8?q?ssage=20when=20building=20a=20connection=20to=20the=20database?= =?UTF-8?q?=20fails.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/backend/langflow/interface/initialize/loading.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/backend/langflow/interface/initialize/loading.py b/src/backend/langflow/interface/initialize/loading.py index 8503290b1..046ca0df6 100644 --- a/src/backend/langflow/interface/initialize/loading.py +++ b/src/backend/langflow/interface/initialize/loading.py @@ -93,8 +93,10 @@ def instantiate_memory(node_type, class_object, params): return class_object(**params) # I want to catch a specific attribute error that happens # when the object does not have a cursor attribute - except AttributeError as exc: - if "object has no attribute 'cursor'" in str(exc): + except Exception as exc: + if "object has no attribute 'cursor'" in str( + exc + ) or 'object has no field "conn"' in str(exc): raise AttributeError( f"Failed to build connection to database. Please check your connection string and try again. Error: {exc}" ) from exc