status

package
v2.6.0 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2022 License: Apache-2.0 Imports: 5 Imported by: 2

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 *message.Message, err error) Status

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

func Errorf

func Errorf(msg *message.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 (se Status) COAPError() Status

COAPError just for check interface

func (Status) Code

func (se Status) Code() codes.Code

Code returns the status code contained in se.

func (Status) Error

func (se Status) Error() string

func (Status) Message

func (se Status) Message() *message.Message

Message returns a coap message.

Jump to

Keyboard shortcuts

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