status

package
v3.9.0 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2026 License: Apache-2.0 Imports: 5 Imported by: 3 modules, 11 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	OK       codes.Code = 10000
	Timeout  codes.Code = 10001
	Canceled codes.Code = 10002
	Unknown  codes.Code = 10003
)

Variables

This section is empty.

Functions

func Code

func Code(err error) codes.Code

Code returns the Code of the error if it is a Status error, codes.OK if err is nil, or codes.Unknown otherwise.

func CodeToString

func CodeToString(c codes.Code) string

Types

type Status

type Status struct {
	// contains filtered or unexported fields
}

Status holds error of coap

func Convert

func Convert(err error) Status

Convert is a convenience function which removes the need to handle the boolean return value from FromError.

func Error

func Error(msg *pool.Message, err error) Status

Error returns an error representing c and msg. If c is OK, returns nil.

func Errorf

func Errorf(msg *pool.Message, format string, a ...interface{}) Status

Errorf returns Error(c, fmt.Sprintf(format, a...)).

func FromContextError

func FromContextError(err error) Status

FromContextError converts a context error into a Status. It returns a Status with codes.OK if err is nil, or a Status with codes.Unknown if err is non-nil and not a context error.

func FromError

func FromError(err error) (s Status, ok bool)

FromError returns a Status representing err if it was produced from this package or has a method `COAPError() Status`. Otherwise, ok is false and a Status is returned with codes.Unknown and the original error message.

func (Status) COAPError

func (s Status) COAPError() Status

COAPError just for check interface

func (Status) Code

func (s Status) Code() codes.Code

Code returns the status code contained in s.

func (Status) Error

func (s Status) Error() string

func (Status) Message

func (s Status) Message() *pool.Message

Message returns a coap message.

func (Status) Unwrap added in v3.0.1

func (s Status) Unwrap() error

Unwrap unpacks wrapped errors.

Jump to

Keyboard shortcuts

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