From ae5bc1e20336be86f5e71bb7abb6d832c7c26e56 Mon Sep 17 00:00:00 2001 From: gustavoschaedler Date: Wed, 5 Jul 2023 16:23:32 +0100 Subject: [PATCH] Refactor custom.py for better error handling - Modifies the `CustomComponent` class to handle errors using `HTTPException` from FastAPI - Removes the unused `HTTPExceptionWithTraceback` class - Updates the error response format with `err.msg` and `traceback.format_exc()` --- src/backend/langflow/interface/tools/custom.py | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/src/backend/langflow/interface/tools/custom.py b/src/backend/langflow/interface/tools/custom.py index 6e124dc52..02bba9798 100644 --- a/src/backend/langflow/interface/tools/custom.py +++ b/src/backend/langflow/interface/tools/custom.py @@ -12,12 +12,6 @@ from langchain.agents.tools import Tool from fastapi import HTTPException -class HTTPExceptionWithTraceback(HTTPException): - def __init__(self, status_code, detail=None, traceback=None): - super().__init__(status_code, detail) - self.traceback = traceback - - class Function(BaseModel): code: str function: Optional[Callable] = None @@ -170,13 +164,8 @@ class CustomComponent(BaseModel): detail={ 'error': err.msg, 'traceback': traceback.format_exc() - } - ) - # raise HTTPExceptionWithTraceback( - # status_code=400, - # detail=err.msg, - # traceback=traceback.format_exc() - # ) from err + }, + ) from err for node in module.body: if isinstance(node, (ast.Import, ast.ImportFrom)):