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:
  • Constructor Details

    • 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
    • CloseException

      public CloseException(CloseStatus closeStatus, ContextView context, @Nullable Throwable cause)
      Create a CloseException with the given status, Reactor context and cause.
      Parameters:
      closeStatus - the CloseStatus representing this exception
      context - a ContextView instance providing metadata related to this exception
      cause - the cause for this exception
  • Method Details

    • 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
    • getMessage

      public String getMessage()
      Overrides:
      getMessage in class Throwable