🐛 fix(chat.py): handle and log any exception that occurs in the chat websocket to prevent unhandled errors and provide better error messages

This commit is contained in:
Gabriel Luiz Freitas Almeida 2023-08-30 17:54:58 -03:00
commit 9d7deccc53

View file

@ -59,6 +59,9 @@ async def chat(
except WebSocketException as exc:
logger.error(f"Websocket error: {exc}")
await websocket.close(code=status.WS_1011_INTERNAL_ERROR, reason=str(exc))
except Exception as exc:
logger.error(f"Error in chat websocket: {exc}")
await websocket.close(code=status.WS_1011_INTERNAL_ERROR, reason=str(exc))
@router.post("/build/init/{flow_id}", response_model=InitResponse, status_code=201)