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
| Name | Type | Description |
|---|---|---|
| websocket | WebSocket | The WebSocket connection object to be closed. |
| exc | WebSocketRequestValidationError | The exception object containing details about the request validation errors. |
Returns
| Type | Description |
|---|---|
None | This function does not return any value; it closes the WebSocket connection. |