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 aCloseExceptionwith the given status and Reactor context.CloseException(CloseStatus closeStatus, ContextView context, Throwable cause) Create aCloseExceptionwith the given status, Reactor context and cause. -
Method Summary
Modifier and TypeMethodDescriptionReturn the underlyingCloseStatusthat triggered this exception.intgetCode()Return the websocket close code.Return the ReactorContextViewproviding 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 aCloseExceptionwith the given status and Reactor context.- Parameters:
closeStatus- theCloseStatusrepresenting this exceptioncontext- aContextViewinstance representing metadata related to this exception
-
CloseException
Create aCloseExceptionwith the given status, Reactor context and cause.- Parameters:
closeStatus- theCloseStatusrepresenting this exceptioncontext- aContextViewinstance providing metadata related to this exceptioncause- the cause for this exception
-
-
Method Details
-
getCloseStatus
Return the underlyingCloseStatusthat 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
Optionalcontaining a close reason if present, or empty otherwise
-
getContext
Return the ReactorContextViewproviding metadata about this exception.- Returns:
- a Reactor context instance
-
getMessage
- Overrides:
getMessagein classThrowable
-