util

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2023 License: Apache-2.0 Imports: 9 Imported by: 19

Documentation

Overview

Package util ...

Package util ...

Package util ...

Package util ...

Package util ...

Index

Constants

View Source
const (
	// FailedAccessToken ...
	FailedAccessToken = "FailedAccessToken"

	// ProvisioningFailed volume or snapshot provisioning failed
	ProvisioningFailed = "ProvisioningFailed"

	// DeletionFailed ...
	DeletionFailed = "DeletionFailed"

	// UpdateFailed ...
	UpdateFailed = "UpdateFailed"

	// RetrivalFailed ...
	RetrivalFailed = "RetrivalFailed"

	// InvalidRequest ...
	InvalidRequest = "InvalidRequest"

	// EntityNotFound ...
	EntityNotFound = "EntityNotFound"

	// PermissionDenied ...
	PermissionDenied = "PermissionDenied"

	// Unauthenticated ...
	Unauthenticated = "Unauthenticated"

	// ErrorTypeFailed ...
	ErrorTypeFailed = "ErrorTypeConversionFailed"

	// VolumeAttachFindFailed ...
	VolumeAttachFindFailed = "VolumeAttachFindFailed"

	// AttachFailed ...
	AttachFailed = "AttachFailed"

	// VolumeAccessPointFindFailed ...
	VolumeAccessPointFindFailed = "VolumeAccessPointFindFailed"

	// CreateVolumeAccessPointFailed ...
	CreateVolumeAccessPointFailed = "CreateVolumeAccessPointFailed"

	// DeleteVolumeAccessPointFailed ...
	DeleteVolumeAccessPointFailed = "DeleteVolumeAccessPointFailed"

	// InstanceNotFound ...
	NodeNotFound = "NodeNotFound"

	// DetachFailed ...
	DetachFailed = "DetachFailed"

	// ExpansionFailed ...
	ExpansionFailed = "ExpansionFailed"
)

These are the error types which all provider should categorize their errors

Variables

This section is empty.

Functions

func ErrorDeepUnwrapString

func ErrorDeepUnwrapString(err error) []string

ErrorDeepUnwrapString returns the full list of unwrapped error strings Returns empty slice if not a provider.Error

func ErrorReasonCode

func ErrorReasonCode(err error) reasoncode.ReasonCode

ErrorReasonCode returns reason code if a provider.Error, else ErrorUnclassified

func ErrorToFault

func ErrorToFault(err error) *provider.Fault

ErrorToFault returns or builds a Fault pointer for an error (e.g. for a response object) Returns nil if no error,

func FaultToError

func FaultToError(fault *provider.Fault) error

FaultToError builds a Error from a Fault pointer (e.g. from a response object) Returns nil error if no Fault.

func GetErrorType

func GetErrorType(err error) string

GetErrorType return the user error type provided by volume provider

func NewError

func NewError(code reasoncode.ReasonCode, msg string, wrapped ...error) error

NewError returns an error that is implemented by provider.Error. If optional wrapped errors are a provider.Error, this preserves all child wrapped errors in depth-first order.

func NewErrorWithProperties

func NewErrorWithProperties(code reasoncode.ReasonCode, msg string, properties map[string]string, wrapped ...error) error

NewErrorWithProperties returns an error that is implemented provider.Error and which is decorated with diagnostic properties. If optional wrapped errors are a provider.Error, this preserves all child wrapped errors in depth-first order.

func SafeStringValue

func SafeStringValue(s *string) string

SafeStringValue returns the referenced string value, treating nil as equivalent to "". It is intended as a type-safe and nil-safe test for empty values in data fields of

func SetFaultResponse

func SetFaultResponse(fault error, response interface{}) error

SetFaultResponse sets the Fault field of any response struct

func StringHasValue

func StringHasValue(s *string) bool

StringHasValue returns true if the argument is neither nil nor a pointer to the zero/empty string.

func TimeTracker

func TimeTracker(functionName string, start time.Time)

TimeTracker Get execution time of a function

func ZapError

func ZapError(err error) zapcore.Field

ZapError returns a zapcore.Field for an error that includes the metadata associated with a provider.Error. If the error is not a provider.Error then the standard zap.Error is used.

Types

type ErrorRetrier

type ErrorRetrier struct {
	MaxAttempts   int
	RetryInterval time.Duration
	Logger        *zap.Logger
}

ErrorRetrier retry the function

func NewErrorRetrier

func NewErrorRetrier(maxAttempt int, retryInterval time.Duration, logger *zap.Logger) *ErrorRetrier

NewErrorRetrier return new ErrorRetrier

func (*ErrorRetrier) ErrorRetry

func (er *ErrorRetrier) ErrorRetry(funcToRetry func() (error, bool)) error

ErrorRetry path for retry logic with logger passed in

type Message

type Message struct {
	Code         string
	Type         string
	RequestID    string
	Description  string
	BackendError string
	RC           int
	Action       string
}

Message Wrapper Message/Error Class

func (Message) Error

func (msg Message) Error() string

Error Implement the Error() interface method

func (Message) Info

func (msg Message) Info() string

Info ...

Directories

Path Synopsis
Package reasoncode ...
Package reasoncode ...

Jump to

Keyboard shortcuts

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