Documentation ¶
Overview ¶
Package wserr declares WebSocket error types and implements functions to pass WebSocket errors using context.
Index ¶
- func GetOperationError(ctx context.Context) error
- func GetTimeoutError(ctx context.Context) error
- func PrepareOperationContext(ctx context.Context) context.Context
- func SetOperationError(ctx context.Context, err error)
- func SetTimeoutError(ctx context.Context, err error) context.Context
- type CloseError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetOperationError ¶
GetOperationError retrieves the operation error stored in the context, or nil if no error has been stored.
The context must have been prepared with PrepareOperationContext, otherwise GetOperationError returns nil.
func GetTimeoutError ¶
GetTimeoutError retrieves the timeout error stored in the context, or nil if no error has been stored.
func PrepareOperationContext ¶
PrepareOperationContext prepares a context for use with SetOperationError and GetOperationError.
func SetOperationError ¶
SetOperationError stores an operation error in the context.
It can be retrieved later with GetOperationError.
The context must have been prepared with PrepareOperationContext, otherwise SetOperationError does nothing.
Types ¶
type CloseError ¶
type CloseError struct { // Code is sent to the client in the close frame. Code int // Reason is sent to the client in the close frame. Reason string Err error }
CloseError represents a WebSocket close error.
func (CloseError) Error ¶
func (e CloseError) Error() string
func (CloseError) StatusCode ¶
func (e CloseError) StatusCode() websocket.StatusCode
func (CloseError) Unwrap ¶
func (e CloseError) Unwrap() error