errors

package
v0.23.9 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2024 License: Apache-2.0 Imports: 9 Imported by: 43

Documentation

Overview

Copyright (c) Microsoft Corporation. Licensed under the Apache v2.0 license.

Index

Constants

This section is empty.

Variables

View Source
var (
	NotFound                    error = NewMocError(moccodes.NotFound)
	Degraded                    error = NewMocError(moccodes.Degraded)
	InvalidConfiguration        error = NewMocError(moccodes.InvalidConfiguration)
	InvalidInput                error = NewMocError(moccodes.InvalidInput)
	InvalidType                 error = NewMocError(moccodes.InvalidType)
	NotSupported                error = NewMocError(moccodes.NotSupported)
	AlreadyExists               error = NewMocError(moccodes.AlreadyExists)
	InUse                       error = NewMocError(moccodes.InUse)
	Duplicates                  error = NewMocError(moccodes.Duplicates)
	InvalidFilter               error = NewMocError(moccodes.InvalidFilter)
	Failed                      error = NewMocError(moccodes.Failed)
	InvalidGroup                error = NewMocError(moccodes.InvalidGroup)
	InvalidVersion              error = NewMocError(moccodes.InvalidVersion)
	OldVersion                  error = NewMocError(moccodes.OldVersion)
	OutOfCapacity               error = NewMocError(moccodes.OutOfCapacity)
	OutOfNodeCapacity           error = NewMocError(moccodes.OutOfNodeCapacity)
	OutOfMemory                 error = NewMocError(moccodes.OutOfMemory)
	UpdateFailed                error = NewMocError(moccodes.UpdateFailed)
	NotInitialized              error = NewMocError(moccodes.NotInitialized)
	NotImplemented              error = NewMocError(moccodes.NotImplemented)
	OutOfRange                  error = NewMocError(moccodes.OutOfRange)
	AlreadySet                  error = NewMocError(moccodes.AlreadySet)
	NotSet                      error = NewMocError(moccodes.NotSet)
	InconsistentState           error = NewMocError(moccodes.InconsistentState)
	PendingState                error = NewMocError(moccodes.PendingState)
	WrongHost                   error = NewMocError(moccodes.WrongHost)
	PoolFull                    error = NewMocError(moccodes.PoolFull)
	NoActionTaken               error = NewMocError(moccodes.NoActionTaken)
	Expired                     error = NewMocError(moccodes.Expired)
	Revoked                     error = NewMocError(moccodes.Revoked)
	Timeout                     error = NewMocError(moccodes.Timeout)
	RunCommandFailed            error = NewMocError(moccodes.RunCommandFailed)
	InvalidToken                error = NewMocError(moccodes.InvalidToken)
	Unknown                     error = NewMocError(moccodes.Unknown)
	DeleteFailed                error = NewMocError(moccodes.DeleteFailed)
	DeletePending               error = NewMocError(moccodes.DeletePending)
	FileNotFound                error = NewMocError(moccodes.FileNotFound)
	PathNotFound                error = NewMocError(moccodes.PathNotFound)
	NotEnoughSpace              error = NewMocError(moccodes.NotEnoughSpace)
	AccessDenied                error = NewMocError(moccodes.AccessDenied)
	BlobNotFound                error = NewMocError(moccodes.BlobNotFound)
	GenericFailure              error = NewMocError(moccodes.GenericFailure)
	NoAuthenticationInformation error = NewMocError(moccodes.NoAuthenticationInformation)
	MeasurementUnitError        error = NewMocError(moccodes.MeasurementUnitError)
	QuotaViolation              error = NewMocError(moccodes.QuotaViolation)
	IPOutOfRange                error = NewMocError(moccodes.IPOutOfRange)
)

Functions

func ErrorToProto added in v0.23.2

func ErrorToProto(err error) *common.Error

ErrorToProto converts an error to a protobuf common.Error by extracting the MocCode and message.

func GetErrorCode added in v0.10.8

func GetErrorCode(err error) string

func GetGRPCError

func GetGRPCError(err error) error

GetGRPCError is used when returning errors from MOC GRPC services. It adds the MocCode to the error status details.

func GetGRPCErrorCode

func GetGRPCErrorCode(err error) codes.Code

func GetMocErrorCode added in v0.23.2

func GetMocErrorCode(err error) moccodes.MocCode

GetMocErrorCode attempts to extract the MocCode from the given error. If the error is a multierr, it will return the MocCode if all errors in the multierr match the same MocCode. Otherwise, it returns MocCode.Unknown.

GetMocErrorCode follows the following rules when parsing individual errors:

  • If the error is nil, it returns MocCode.OK.
  • If the error is of type MocError, it returns the MocCode.
  • If the error has a Cause that is not nil and is of type MocError, it returns the MocCode of the Cause.
  • If both the error and its Cause are not of type MocError, it returns MocCode.Unknown.

func IsAccessDenied added in v0.10.31

func IsAccessDenied(err error) bool

func IsAlreadyExists

func IsAlreadyExists(err error) bool

func IsAlreadySet

func IsAlreadySet(err error) bool

func IsBlobNotFound added in v0.13.2

func IsBlobNotFound(err error) bool

func IsDegraded

func IsDegraded(err error) bool

func IsDeleteFailed added in v0.10.20

func IsDeleteFailed(err error) bool

func IsDeletePending added in v0.10.20

func IsDeletePending(err error) bool

func IsDuplicates added in v0.10.8

func IsDuplicates(err error) bool

func IsErrDeadlineExceeded added in v0.10.15

func IsErrDeadlineExceeded(err error) bool

func IsExpired added in v0.10.8

func IsExpired(err error) bool

func IsFailed added in v0.10.8

func IsFailed(err error) bool

func IsFileNotFound added in v0.10.31

func IsFileNotFound(err error) bool

func IsGRPCAborted

func IsGRPCAborted(err error) bool

func IsGRPCAlreadyExist

func IsGRPCAlreadyExist(err error) bool

func IsGRPCDeadlineExceeded

func IsGRPCDeadlineExceeded(err error) bool

func IsGRPCNotFound

func IsGRPCNotFound(err error) bool

func IsGRPCUnavailable

func IsGRPCUnavailable(err error) bool

func IsGRPCUnknown

func IsGRPCUnknown(err error) bool

func IsGenericFailure added in v0.13.2

func IsGenericFailure(err error) bool

func IsIPOutOfRange added in v0.13.2

func IsIPOutOfRange(err error) bool

func IsInUse

func IsInUse(err error) bool

func IsInconsistentState

func IsInconsistentState(err error) bool

func IsInvalidConfiguration

func IsInvalidConfiguration(err error) bool

func IsInvalidFilter added in v0.10.8

func IsInvalidFilter(err error) bool

func IsInvalidGroup

func IsInvalidGroup(err error) bool

func IsInvalidInput

func IsInvalidInput(err error) bool

func IsInvalidToken added in v0.10.14

func IsInvalidToken(err error) bool

func IsInvalidType added in v0.10.28

func IsInvalidType(err error) bool

func IsInvalidVersion

func IsInvalidVersion(err error) bool

func IsMeasurementUnitError added in v0.13.2

func IsMeasurementUnitError(err error) bool

func IsMocErrorCode added in v0.23.2

func IsMocErrorCode(err error, code moccodes.MocCode) bool

IsMocErrorCode wraps a call to GetMocErrorCode. It returns true only if the error has the same MocCode as the given code (no string matching).

func IsNoActionTaken

func IsNoActionTaken(err error) bool

func IsNoAuthenticationInformation added in v0.13.2

func IsNoAuthenticationInformation(err error) bool

func IsNotEnoughSpace added in v0.10.31

func IsNotEnoughSpace(err error) bool

func IsNotFound

func IsNotFound(err error) bool

func IsNotImplemented added in v0.10.8

func IsNotImplemented(err error) bool

func IsNotInitialized

func IsNotInitialized(err error) bool

func IsNotSet

func IsNotSet(err error) bool

func IsNotSupported

func IsNotSupported(err error) bool

func IsOldVersion added in v0.10.8

func IsOldVersion(err error) bool

func IsOutOfCapacity added in v0.10.7

func IsOutOfCapacity(err error) bool

func IsOutOfMemory

func IsOutOfMemory(err error) bool

func IsOutOfNodeCapacity added in v0.10.28

func IsOutOfNodeCapacity(err error) bool

func IsOutOfRange

func IsOutOfRange(err error) bool

func IsPathNotFound added in v0.10.31

func IsPathNotFound(err error) bool

func IsPendingState

func IsPendingState(err error) bool

func IsPoolFull

func IsPoolFull(err error) bool

func IsQuotaViolation added in v0.13.2

func IsQuotaViolation(err error) bool

func IsRevoked added in v0.10.8

func IsRevoked(err error) bool

func IsRunCommandFailed added in v0.10.28

func IsRunCommandFailed(err error) bool

func IsTimeout added in v0.10.8

func IsTimeout(err error) bool

func IsUnknown added in v0.10.8

func IsUnknown(err error) bool

func IsUpdateFailed added in v0.10.8

func IsUpdateFailed(err error) bool

func IsWrongHost

func IsWrongHost(err error) bool

func New

func New(errString string) error

func NewMocError added in v0.23.2

func NewMocError(code moccodes.MocCode) error

NewMocError creates a new MocError based on the given MocCode and message. If code is OK, it will return nil.

func ParseGRPCError added in v0.23.2

func ParseGRPCError(err error) error

ParseGRPCError is when parsing errors from MOC GRPC services. Will extract the error as a MocError if GRPC code is Unknown.

func ProtoToMocError added in v0.23.2

func ProtoToMocError(protoErr *common.Error) error

ProtoToMocError converts a protobuf common.Error to a MocError.

func Wrap

func Wrap(cause error, message string) error

func Wrapf

func Wrapf(err error, format string, args ...interface{}) error

Types

type MocError added in v0.23.2

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

MocError is an implementation of error that wraps a MocCode and an error message.

func (*MocError) Error added in v0.23.2

func (e *MocError) Error() string

func (*MocError) GetMocCode added in v0.23.2

func (e *MocError) GetMocCode() moccodes.MocCode

GetMocCode returns the underlying MocCode of the MocError.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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