Skip to content

Commit

Permalink
feat: enhance error handling in build_flow to capture and report HTTP…
Browse files Browse the repository at this point in the history
… exceptions in the flow building process
  • Loading branch information
ogabrielluiz committed Aug 9, 2024
1 parent 6462d71 commit 35bf3ba
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/backend/base/langflow/api/v1/chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,10 +356,23 @@ async def event_generator(queue: asyncio.Queue, client_consumed_queue: asyncio.Q
except asyncio.CancelledError:
vertices_task.cancel()
return
except Exception as e:
if isinstance(e, HTTPException):
send_event("error", {"error": str(e.detail), "statusCode": e.status_code}, queue)
raise e
send_event("error", {"error": str(e)}, queue)
raise e

ids, vertices_to_run, graph = vertices_task.result()
else:
ids, vertices_to_run, graph = await build_graph_and_get_order()
try:
ids, vertices_to_run, graph = await build_graph_and_get_order()
except Exception as e:
if isinstance(e, HTTPException):
send_event("error", {"error": str(e.detail), "statusCode": e.status_code}, queue)
raise e
send_event("error", {"error": str(e)}, queue)
raise e
send_event("vertices_sorted", {"ids": ids, "to_run": vertices_to_run}, queue)
await client_consumed_queue.get()

Expand Down

0 comments on commit 35bf3ba

Please sign in to comment.