package status
import "github.com/plgd-dev/go-coap/v3/message/status"
Index ¶
- Constants
- func Code(err error) codes.Code
- func CodeToString(c codes.Code) string
- type Status
- func Convert(err error) Status
- func Error(msg *pool.Message, err error) Status
- func Errorf(msg *pool.Message, format string, a ...interface{}) Status
- func FromContextError(err error) Status
- func FromError(err error) (s Status, ok bool)
- func (s Status) COAPError() Status
- func (s Status) Code() codes.Code
- func (s Status) Error() string
- func (s Status) Message() *pool.Message
- func (s Status) Unwrap() error
Constants ¶
const ( OK codes.Code = 10000 Timeout codes.Code = 10001 Canceled codes.Code = 10002 Unknown codes.Code = 10003 )
Functions ¶
func 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 ¶
Types ¶
type Status ¶
type Status struct {
// contains filtered or unexported fields
}
Status holds error of coap
func Convert ¶
Convert is a convenience function which removes the need to handle the boolean return value from FromError.
func Error ¶
Error returns an error representing c and msg. If c is OK, returns nil.
func Errorf ¶
Errorf returns Error(c, fmt.Sprintf(format, a...)).
func FromContextError ¶
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 ¶
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 ¶
COAPError just for check interface
func (Status) Code ¶
Code returns the status code contained in s.
func (Status) Error ¶
func (Status) Message ¶
Message returns a coap message.
func (Status) Unwrap ¶
Unwrap unpacks wrapped errors.
Source Files ¶
- Version
- v3.3.6 (latest)
- Published
- Sep 18, 2024
- Platform
- linux/amd64
- Imports
- 5 packages
- Last checked
- 1 week ago –
Tools for package owners.