package status

import "github.com/plgd-dev/go-coap/v3/message/status"

Index

Constants

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

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

func (s Status) Unwrap() error

Unwrap unpacks wrapped errors.

Source Files

status.go

Version
v3.3.6 (latest)
Published
Sep 18, 2024
Platform
linux/amd64
Imports
5 packages
Last checked
1 week ago

Tools for package owners.