org.springframework.web.socket.messaging

## Interface SubProtocolErrorHandler<P>

Type Parameters:
  `P` - the message payload type

All Known Implementing Classes:
  StompSubProtocolErrorHandler

    public interface SubProtocolErrorHandler<P>

A contract for handling sub-protocol errors sent to clients.

Since:
  4.2
Author:
  Rossen Stoyanchev

### Method Summary

All Methods Instance Methods Abstract Methods
`org.springframework.messaging.Message<P>` `handleClientMessageProcessingError(org.springframework.messaging.Message<P> clientMessage, Throwable ex)` Handle errors thrown while processing client messages providing an opportunity to prepare the error message or to prevent one from being sent.
`org.springframework.messaging.Message<P>` `handleErrorMessageToClient(org.springframework.messaging.Message<P> errorMessage)` Handle errors sent from the server side to clients, e.g.

### Method Detail

#### handleClientMessageProcessingError

    @Nullable
    org.springframework.messaging.Message<P> handleClientMessageProcessingError(@Nullable
                                                                                          org.springframework.messaging.Message<P> clientMessage,
                                                                                          Throwable ex)

Handle errors thrown while processing client messages providing an opportunity to prepare the error message or to prevent one from being sent.

Note that the STOMP protocol requires a server to close the connection after sending an ERROR frame. To prevent an ERROR frame from being sent, a handler could return `null` and send a notification message through the broker instead, e.g. via a user destination.

Parameters:
  `clientMessage` - the client message related to the error, possibly `null` if error occurred while parsing a WebSocket message
  `ex` - the cause for the error, never `null`
Returns:
  the error message to send to the client, or `null` in which case no message will be sent.

#### handleErrorMessageToClient

    @Nullable
    org.springframework.messaging.Message<P> handleErrorMessageToClient(org.springframework.messaging.Message<P> errorMessage)

Handle errors sent from the server side to clients, e.g. errors from the `"broke relay"` because connectivity failed or the external broker sent an error message, etc.

Parameters:
  `errorMessage` - the error message, never `null`
Returns:
  the error message to send to the client, or `null` in which case no message will be sent.