Skip to content

Commit

Permalink
🐛 fix(loading.py): catch additional exception when object has no 'con…
Browse files Browse the repository at this point in the history
…n' field to improve error handling

The code now catches an additional exception when the object does not have a 'conn' field. This improves the error handling by providing a more specific error message when building a connection to the database fails.
  • Loading branch information
ogabrielluiz committed Jun 29, 2023
1 parent 4761eda commit 08c7bb5
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/backend/langflow/interface/initialize/loading.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 08c7bb5

Please sign in to comment.