status

package
v3.1.1 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2023 License: Apache-2.0 Imports: 5 Imported by: 11

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