websocket_request_validation_exception_handler
Closes a WebSocket connection with a policy violation code and provides the validation error details as the closure reason.
def websocket_request_validation_exception_handler(
websocket: WebSocket,
exc: WebSocketRequestValidationError
) - > None
Handles WebSocket request validation errors by closing the connection with a policy violation code and a JSON-encoded reason for the failure.
Parameters
| Name | Type | Description |
|---|---|---|
| websocket | WebSocket | The active WebSocket connection instance that encountered the validation error. |
| exc | WebSocketRequestValidationError | The exception object containing the specific validation errors to be encoded and sent as the closure reason. |
Returns
| Type | Description |
|---|---|
None | Nothing is returned; the function performs an asynchronous side effect of closing the WebSocket connection. |