🐛 fix(loading.py): improve error message formatting when failing to build connection to database

🐛 fix(base.py): add optional 'name' parameter to the format method in FieldFormatter
In loading.py, the error message when failing to build a connection to the database is now formatted in a more readable way. This improves the clarity of the error message and makes it easier to identify the cause of the issue.

In base.py, the format method in FieldFormatter now accepts an optional 'name' parameter. This allows for more flexibility when formatting the field and provides the ability to include the field name in the formatting process if needed.
This commit is contained in:
Gabriel Luiz Freitas Almeida 2023-06-29 19:36:04 -03:00
commit b188400517
2 changed files with 6 additions and 2 deletions

View file

@ -98,7 +98,10 @@ def instantiate_memory(node_type, class_object, params):
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}"
(
"Failed to build connection to database."
f" Please check your connection string and try again. Error: {exc}"
)
) from exc
raise exc

View file

@ -1,9 +1,10 @@
from abc import ABC, abstractmethod
from typing import Optional
from langflow.template.field.base import TemplateField
class FieldFormatter(ABC):
@abstractmethod
def format(self, field: TemplateField):
def format(self, field: TemplateField, name: Optional[str]) -> None:
pass