# Class CloseReason

java.lang.Object
jakarta.websocket.CloseReason

public class CloseReason extends Object
Represents the reason for the closure of a WebSocket connection, including a close code and an optional reason phrase.

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Class
  Description
  `static interface`
  `CloseReason.CloseCode`
  Represents a WebSocket close code.
  `static enum`
  `CloseReason.CloseCodes`
  Standard WebSocket close codes as defined by RFC 6455 and related specifications.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `CloseReason(CloseReason.CloseCode closeCode, String reasonPhrase)`
  Creates a new CloseReason with the given close code and reason phrase.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `CloseReason.CloseCode`
  `getCloseCode()`
  Returns the close code.
  `String`
  `getReasonPhrase()`
  Returns the reason phrase.
  `String`
  `toString()`

  ### Methods inherited from class Object

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

- ## Constructor Details

  - ### CloseReason

    public CloseReason(CloseReason.CloseCode closeCode, String reasonPhrase)
    Creates a new CloseReason with the given close code and reason phrase.
    Parameters:
      `closeCode` - The close code
      `reasonPhrase` - The reason phrase explaining the closure

- ## Method Details

  - ### getCloseCode

    public CloseReason.CloseCode getCloseCode()
    Returns the close code.
    Returns:
      The close code

  - ### getReasonPhrase

    public String getReasonPhrase()
    Returns the reason phrase.
    Returns:
      The reason phrase

  - ### toString

    public String toString()
    Overrides:
      `toString` in class `Object`