org.springframework.web.socket.messaging

## Class StompSubProtocolErrorHandler

- java.lang.Object
- - org.springframework.web.socket.messaging.StompSubProtocolErrorHandler

All Implemented Interfaces:
  SubProtocolErrorHandler<byte[]>

    public class StompSubProtocolErrorHandler
    extends Object
    implements SubProtocolErrorHandler<byte[]>

A `SubProtocolErrorHandler` for use with STOMP.

Since:
  4.2
Author:
  Rossen Stoyanchev

### Constructor Summary

Constructors
Constructor and Description
`StompSubProtocolErrorHandler()`

### Method Summary

All Methods Instance Methods Concrete Methods
`org.springframework.messaging.Message<byte[]>` `handleClientMessageProcessingError(org.springframework.messaging.Message<byte[]> 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<byte[]>` `handleErrorMessageToClient(org.springframework.messaging.Message<byte[]> errorMessage)` Handle errors sent from the server side to clients, e.g.
`protected org.springframework.messaging.Message<byte[]>` `handleInternal(org.springframework.messaging.simp.stomp.StompHeaderAccessor errorHeaderAccessor, byte[] errorPayload, Throwable cause, org.springframework.messaging.simp.stomp.StompHeaderAccessor clientHeaderAccessor)`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### StompSubProtocolErrorHandler

    public StompSubProtocolErrorHandler()

### Method Detail

#### handleClientMessageProcessingError

    @Nullable
    public org.springframework.messaging.Message<byte[]> handleClientMessageProcessingError(@Nullable
                                                                                                      org.springframework.messaging.Message<byte[]> clientMessage,
                                                                                                      Throwable ex)

Description copied from interface: `SubProtocolErrorHandler`
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.

Specified by:
  `handleClientMessageProcessingError` in interface `SubProtocolErrorHandler<byte[]>`
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
    public org.springframework.messaging.Message<byte[]> handleErrorMessageToClient(org.springframework.messaging.Message<byte[]> errorMessage)

Description copied from interface: `SubProtocolErrorHandler`
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.

Specified by:
  `handleErrorMessageToClient` in interface `SubProtocolErrorHandler<byte[]>`
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.

#### handleInternal

    protected org.springframework.messaging.Message<byte[]> handleInternal(org.springframework.messaging.simp.stomp.StompHeaderAccessor errorHeaderAccessor,
                                                                           byte[] errorPayload,
                                                                           @Nullable
                                                                           Throwable cause,
                                                                           @Nullable
                                                                           org.springframework.messaging.simp.stomp.StompHeaderAccessor clientHeaderAccessor)