🐛 fix(chat.py): fix typo in variable name 'messsage' to 'message' for better readability

🔧 chore(chat.py): refactor error handling in chat websocket to improve code clarity and maintainability
This commit is contained in:
Gabriel Luiz Freitas Almeida 2023-08-31 11:16:52 -03:00
commit 8429f3fe72

View file

@ -61,14 +61,13 @@ async def chat(
await websocket.close(code=status.WS_1011_INTERNAL_ERROR, reason=str(exc))
except Exception as exc:
logger.error(f"Error in chat websocket: {exc}")
if isinstance(exc, HTTPException):
exc = exc.detail
messsage = exc.detail if isinstance(exc, HTTPException) else str(exc)
if "Could not validate credentials" in str(exc):
await websocket.close(
code=status.WS_1008_POLICY_VIOLATION, reason="Unauthorized"
)
else:
await websocket.close(code=status.WS_1011_INTERNAL_ERROR, reason=str(exc))
await websocket.close(code=status.WS_1011_INTERNAL_ERROR, reason=messsage)
@router.post("/build/init/{flow_id}", response_model=InitResponse, status_code=201)