🐛 fix(chat.py): raise HTTPException instead of returning JSONResponse on stream_build error
The function stream_build was returning a JSONResponse with an error message when an exception was raised. This is not the correct way to handle errors in FastAPI. Instead, we should raise an HTTPException with the appropriate status code and error message.
This commit is contained in:
parent
7b44b18726
commit
d14be904ad
1 changed files with 1 additions and 1 deletions
|
|
@ -105,4 +105,4 @@ async def stream_build(flow_id: str):
|
|||
return StreamingResponse(event_stream(flow_id), media_type="text/event-stream")
|
||||
except Exception as exc:
|
||||
logger.error(exc)
|
||||
return JSONResponse(content={"error": str(exc)})
|
||||
raise HTTPException(status_code=500, detail=str(exc))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue