Class CloseException

  • All Implemented Interfaces:
    Serializable

    public class CloseException
    extends RuntimeException
    Unchecked exception thrown when closing a websocket session, expectedly or not.

    Used to wrap an underlying websocket CloseStatus so clients can retrieve the status code and perform actions after it.

    See Also:
    Serialized Form
    • Constructor Detail

      • CloseException

        public CloseException​(CloseStatus closeStatus,
                              ContextView context)
        Create a CloseException with the given status and Reactor context.
        Parameters:
        closeStatus - the CloseStatus representing this exception
        context - a ContextView instance representing metadata related to this exception
    • Method Detail

      • getCloseStatus

        public CloseStatus getCloseStatus()
        Return the underlying CloseStatus that triggered this exception.
        Returns:
        a close status
      • getCode

        public int getCode()
        Return the websocket close code.
        Returns:
        a websocket close code
      • getReason

        public Optional<String> getReason()
        Return a websocket close reason, if present.
        Returns:
        an Optional containing a close reason if present, or empty otherwise
      • getContext

        public ContextView getContext()
        Return the Reactor ContextView providing metadata about this exception.
        Returns:
        a Reactor context instance