wserr

package
v0.2.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 2, 2022 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package wserr declares WebSocket error types and implements functions to pass WebSocket errors using context.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetOperationError

func GetOperationError(ctx context.Context) error

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

func GetTimeoutError(ctx context.Context) error

GetTimeoutError retrieves the timeout error stored in the context, or nil if no error has been stored.

func PrepareOperationContext

func PrepareOperationContext(ctx context.Context) context.Context

PrepareOperationContext prepares a context for use with SetOperationError and GetOperationError.

func SetOperationError

func SetOperationError(ctx context.Context, err error)

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.

func SetTimeoutError

func SetTimeoutError(ctx context.Context, err error) context.Context

SetTimeoutError returns a new context with a timeout error.

It can be retrieved later with GetTimeoutError.

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL