errors

package
v0.25.0 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const ErrRequeueAfter = "ERR_REQUEUE_AFTER"

ErrRequeueAfter is a special error code that indicates that the current step should be re-queued after a certain time, as some conditions during reconciliation are not met. This should not be used in case there is an actual error during reconciliation.

Variables

This section is empty.

Functions

func MapToLastErrors

func MapToLastErrors(errs []error) []druidv1alpha1.LastError

MapToLastErrors maps a slice of DruidError's and maps these to druidv1alpha1.LastError slice which will be set in the status of an etcd resource.

func New

func New(code druidv1alpha1.ErrorCode, operation string, message string) error

New creates a new DruidError with the given error code, operation and message.

func WrapError

func WrapError(err error, code druidv1alpha1.ErrorCode, operation string, message string) error

WrapError wraps an error and contextual information like code, operation and message to create a DruidError Consumers can use errors.As or errors.Is to check if the error is of type DruidError and get its constituent fields.

Types

type DruidError

type DruidError struct {
	// Code indicates the category of error adding contextual information to the underline error.
	Code druidv1alpha1.ErrorCode
	// Cause is the underline error.
	Cause error
	// Operation is the semantic operation during which this error is created/wrapped.
	Operation string
	// Message is the custom message providing additional context for the error.
	Message string
	// ObservedAt is the time at which the error was observed.
	ObservedAt time.Time
}

DruidError is a custom error that should be used throughout druid which encapsulates the underline error (cause) along with error code and contextual information captured as operation during which an error occurred and any custom message.

func AsDruidError added in v0.23.1

func AsDruidError(err error) *DruidError

AsDruidError returns the given error as a DruidError if it is of type DruidError, otherwise returns nil.

func (*DruidError) Error

func (e *DruidError) Error() string

func (*DruidError) WithCause

func (e *DruidError) WithCause(err error) error

WithCause sets the underline error and returns the DruidError.

Jump to

Keyboard shortcuts

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