Package discord4j.common.close
Class CloseException
java.lang.Object
java.lang.Throwable
java.lang.Exception
java.lang.RuntimeException
discord4j.common.close.CloseException
- All Implemented Interfaces:
Serializable
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 Summary
ConstructorsConstructorDescriptionCloseException
(CloseStatus closeStatus, ContextView context) Create aCloseException
with the given status and Reactor context.CloseException
(CloseStatus closeStatus, ContextView context, Throwable cause) Create aCloseException
with the given status, Reactor context and cause. -
Method Summary
Modifier and TypeMethodDescriptionReturn the underlyingCloseStatus
that triggered this exception.int
getCode()
Return the websocket close code.Return the ReactorContextView
providing metadata about this exception.Return a websocket close reason, if present.Methods inherited from class java.lang.Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
-
Constructor Details
-
CloseException
Create aCloseException
with the given status and Reactor context.- Parameters:
closeStatus
- theCloseStatus
representing this exceptioncontext
- aContextView
instance representing metadata related to this exception
-
CloseException
Create aCloseException
with the given status, Reactor context and cause.- Parameters:
closeStatus
- theCloseStatus
representing this exceptioncontext
- aContextView
instance providing metadata related to this exceptioncause
- the cause for this exception
-
-
Method Details
-
getCloseStatus
Return the underlyingCloseStatus
that triggered this exception.- Returns:
- a close status
-
getCode
public int getCode()Return the websocket close code.- Returns:
- a websocket close code
-
getReason
Return a websocket close reason, if present.- Returns:
- an
Optional
containing a close reason if present, or empty otherwise
-
getContext
Return the ReactorContextView
providing metadata about this exception.- Returns:
- a Reactor context instance
-
getMessage
- Overrides:
getMessage
in classThrowable
-