🐛 fix(loading.py): catch additional exception when object has no 'conn' 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.
This commit is contained in:
parent
4761eda9a0
commit
08c7bb5230
1 changed files with 4 additions and 2 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue