errors

package
v0.1.141 Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2021 License: Apache-2.0 Imports: 4 Imported by: 8

Documentation

Index

Constants

View Source
const (
	ClientErrorCode int = 0
)

Error codes are not defined in HTTP status codes

Variables

This section is empty.

Functions

This section is empty.

Types

type CommonEdgeX

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

CommonEdgeX generalizes an error structure which can be used for any type of EdgeX error.

func NewCommonEdgeX

func NewCommonEdgeX(kind ErrKind, message string, wrappedError error) CommonEdgeX

NewCommonEdgeX creates a new CommonEdgeX with the information provided.

func NewCommonEdgeXWrapper

func NewCommonEdgeXWrapper(wrappedError error) CommonEdgeX

NewCommonEdgeXWrapper creates a new CommonEdgeX to wrap another error to record the function call stacks.

func (CommonEdgeX) Code

func (ce CommonEdgeX) Code() int

Code returns the status code of this error.

func (CommonEdgeX) DebugMessages

func (ce CommonEdgeX) DebugMessages() string

DebugMessages returns a string taking all nested and wrapped operations and errors into account.

func (CommonEdgeX) Error

func (ce CommonEdgeX) Error() string

Error creates an error message taking all nested and wrapped errors into account.

func (CommonEdgeX) Is

func (ce CommonEdgeX) Is(err error) bool

Is determines if an error is of type CommonEdgeX. This is used by the new wrapping and unwrapping features available in Go 1.13 and aids the errors.Is function when determining is an error or any error in the wrapped chain contains an error of a particular type.

func (CommonEdgeX) Message

func (ce CommonEdgeX) Message() string

Message returns the first level error message without further details.

func (CommonEdgeX) Unwrap

func (ce CommonEdgeX) Unwrap() error

Unwrap retrieves the next nested error in the wrapped error chain. This is used by the new wrapping and unwrapping features available in Go 1.13 and aids in traversing the error chain of wrapped errors.

type EdgeX

type EdgeX interface {
	// Error obtains the error message associated with the error.
	Error() string
	// DebugMessages returns a detailed string for debug purpose.
	DebugMessages() string
	// Message returns the first level error message without further details.
	Message() string
	// Code returns the status code of this error.
	Code() int
}

EdgeX provides an abstraction for all internal EdgeX errors. This exists so that we can use this type in our method signatures and return nil which will fit better with the way the Go builtin errors are normally handled.

type ErrKind

type ErrKind string

ErrKind a categorical identifier used to give high-level insight as to the error type.

const (
	// Constant Kind identifiers which can be used to label and group errors.
	KindUnknown             ErrKind = "Unknown"
	KindDatabaseError       ErrKind = "Database"
	KindCommunicationError  ErrKind = "Communication"
	KindEntityDoesNotExist  ErrKind = "NotFound"
	KindContractInvalid     ErrKind = "ContractInvalid"
	KindServerError         ErrKind = "UnexpectedServerError"
	KindLimitExceeded       ErrKind = "LimitExceeded"
	KindDuplicateName       ErrKind = "DuplicateName"
	KindInvalidId           ErrKind = "InvalidId"
	KindServiceUnavailable  ErrKind = "ServiceUnavailable"
	KindNotAllowed          ErrKind = "NotAllowed"
	KindServiceLocked       ErrKind = "ServiceLocked"
	KindNotImplemented      ErrKind = "NotImplemented"
	KindRangeNotSatisfiable ErrKind = "RangeNotSatisfiable"
	KindClientError         ErrKind = "ClientError"
	KindIOError             ErrKind = "IOError"
)

func Kind

func Kind(err error) ErrKind

Kind determines the Kind associated with an error by inspecting the chain of errors. The top-most matching Kind is returned or KindUnknown if no Kind can be determined.

Jump to

Keyboard shortcuts

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