🐛 fix(chat.py): add try-except block to handle exceptions in init_build function
The try-except block was added to handle exceptions that may occur in the init_build function. If an exception occurs, it is logged and an HTTPException with a status code of 500 is returned. This ensures that the server does not crash and provides a more informative error message to the client.
This commit is contained in:
parent
044b01e6ad
commit
8aac63b830
1 changed files with 7 additions and 3 deletions
|
|
@ -36,11 +36,15 @@ async def chat(client_id: str, websocket: WebSocket):
|
|||
async def init_build(graph_data: dict):
|
||||
"""Initialize the build by storing graph data and returning a unique session ID."""
|
||||
|
||||
flow_id = graph_data.get("id")
|
||||
try:
|
||||
flow_id = graph_data.get("id")
|
||||
|
||||
flow_data_store[flow_id] = graph_data
|
||||
flow_data_store[flow_id] = graph_data
|
||||
|
||||
return InitResponse(flowId=flow_id)
|
||||
return InitResponse(flowId=flow_id)
|
||||
except Exception as exc:
|
||||
logger.error(exc)
|
||||
return HTTPException(status_code=500, detail=str(exc))
|
||||
|
||||
|
||||
@router.get("/build/{flow_id}/status", response_model=BuiltResponse)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue