Skip to main content

websocket_request_validation_exception_handler

Closes a WebSocket connection with a policy violation code and the details of a request validation error.

def websocket_request_validation_exception_handler(
websocket: WebSocket,
exc: WebSocketRequestValidationError
) - > None

Closes a WebSocket connection with a policy violation code when a request validation error occurs. This function is used to gracefully handle invalid WebSocket requests by informing the client of the specific validation failures.

Parameters

NameTypeDescription
websocketWebSocketThe WebSocket connection object to be closed.
excWebSocketRequestValidationErrorThe exception object containing details about the request validation errors.

Returns

TypeDescription
NoneThis function does not return any value; it closes the WebSocket connection.