errorx

package
v0.0.86 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	// The Invalid type should not be used, only useful to assert whether or not an error is an MdmError during cast
	ErrorTypeUnspecified        = ErrorType("")
	ErrorTypeAlreadyExists      = ErrorType("ALREADY_EXISTS")
	ErrorTypeFailedPrecondition = ErrorType("FAILED_PRECONDITION")
	ErrorTypeInternal           = ErrorType("INTERNAL")
	ErrorTypeInvalidArgument    = ErrorType("INVALID_ARGUMENT")
	ErrorTypeNotFound           = ErrorType("NOT_FOUND")
	ErrorTypeOutOfRange         = ErrorType("OUT_OF_RANGE")
	ErrorTypeUnimplemented      = ErrorType("UNIMPLEMENTED")
	ErrorTypeUnauthenticated    = ErrorType("UNAUTHENTICATED")
	ErrorTypePermissionDenied   = ErrorType("PERMISSION_DENIED")
)

Variables

This section is empty.

Functions

func IsAlreadyExistsError added in v0.0.25

func IsAlreadyExistsError(e error) bool

func IsFailedPreconditionError

func IsFailedPreconditionError(e error) bool

func IsInternalError added in v0.0.25

func IsInternalError(e error) bool

func IsInvalidArgumentError added in v0.0.37

func IsInvalidArgumentError(e error) bool

func IsNotFoundError

func IsNotFoundError(e error) bool

func IsOutOfRange added in v0.0.37

func IsOutOfRange(e error) bool

func IsPermissionDeniedError added in v0.0.43

func IsPermissionDeniedError(e error) bool

func IsUnauthenticatedError added in v0.0.43

func IsUnauthenticatedError(e error) bool

func IsUnimplemented added in v0.0.37

func IsUnimplemented(e error) bool

func PanicsWithCliniaError added in v0.0.67

func PanicsWithCliniaError(t *testing.T, expected CliniaError, f func())

PanicsWithCliniaError asserts that the provided function panics with the expected CliniaError. This is functionally equivalent to require.PanicsWithValue, but with a CliniaError (since our error type contains slices which are not comparable with the `==` operator).

Types

type CliniaError

type CliniaError struct {
	Type    ErrorType `json:"type"`
	Message string    `json:"message"`

	// Not returned to clients
	OriginalError error
	// List of errors that caused the error if applicable
	Details []CliniaError
}

func AlreadyExistsErrorf added in v0.0.25

func AlreadyExistsErrorf(format string, args ...interface{}) CliniaError

AlreadyExistsErrorf creates a CliniaError with type ErrorTypeAlreadyExists and a formatted message

func FailedPreconditionErrorf added in v0.0.25

func FailedPreconditionErrorf(format string, args ...interface{}) CliniaError

FailedPreconditionErrorf creates a CliniaError with type ErrorTypeFailedPrecondition and a formatted message

func InternalErrorf added in v0.0.25

func InternalErrorf(format string, args ...interface{}) CliniaError

InternalErrorf creates a CliniaError with type ErrorTypeInternal and a formatted message

func InvalidArgumentErrorf added in v0.0.37

func InvalidArgumentErrorf(format string, args ...interface{}) CliniaError

InvalidArgumentErrorf creates a CliniaError with type ErrorTypeInvalidArgument and a formatted message

func IsCliniaError

func IsCliniaError(e error) (*CliniaError, bool)

func NewAlreadyExistsError deprecated

func NewAlreadyExistsError(message string) CliniaError

Deprecated: use AlreadyExistsErrorf instead

func NewCliniaErrorFromMessage

func NewCliniaErrorFromMessage(msg string) (*CliniaError, error)

func NewEnumOutOfRangeError

func NewEnumOutOfRangeError(actual string, expectedOneOf []string, enumName string) CliniaError

func NewFailedPreconditionError deprecated

func NewFailedPreconditionError(message string) CliniaError

Deprecated: use FailedPreconditionErrorf instead

func NewInternalError deprecated

func NewInternalError(e error) CliniaError

Deprecated: use InternalErrorf instead

func NewMultipleOutOfRangeError

func NewMultipleOutOfRangeError(actual []string, expectedOneOf []string) CliniaError

func NewNotFoundError deprecated

func NewNotFoundError(msg string, err error) CliniaError

Deprecated: use NotFoundErrorf instead

func NewSingleOutOfRangeError

func NewSingleOutOfRangeError(actual string, expectedOneOf []string) CliniaError

func NotFoundErrorf added in v0.0.25

func NotFoundErrorf(format string, args ...interface{}) CliniaError

NotFoundErrorf creates a CliniaError with type ErrorTypeNotFound and a formatted message

func OutOfRangeErrorf added in v0.0.37

func OutOfRangeErrorf(format string, args ...interface{}) CliniaError

OutOfRangeErrorf creates a CliniaError with type ErrorTypeOutOfRange and a formatted message

func PermissionDeniedErrorf added in v0.0.43

func PermissionDeniedErrorf(format string, args ...interface{}) CliniaError

PermissionDeniedErrorf creates a CliniaError with type ErrorTypePermissionDenied and a formatted message

func UnauthenticatedErrorf added in v0.0.43

func UnauthenticatedErrorf(format string, args ...interface{}) CliniaError

UnauthenticatedErrorf creates a CliniaError with type ErrorTypeUnauthenticated and a formatted message

func UnimplementedErrorf added in v0.0.37

func UnimplementedErrorf(format string, args ...interface{}) CliniaError

UnimplementedErrorf creates a CliniaError with type ErrorTypeUnimplemented and a formatted message

func (*CliniaError) AsRetryableError added in v0.0.80

func (c *CliniaError) AsRetryableError() RetryableError

func (CliniaError) Error

func (e CliniaError) Error() string

func (*CliniaError) IsRetryable added in v0.0.80

func (c *CliniaError) IsRetryable() bool

func (*CliniaError) WithDetails added in v0.0.66

func (c *CliniaError) WithDetails(details ...CliniaError) CliniaError

WithDetails allows to attach multiple errors to the error

type ErrorType

type ErrorType string

func ParseErrorType

func ParseErrorType(s string) (ErrorType, error)

func (ErrorType) String

func (e ErrorType) String() string

func (ErrorType) Validate added in v0.0.22

func (e ErrorType) Validate() error

type RetryableError added in v0.0.80

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

func IsRetryableError added in v0.0.80

func IsRetryableError(err error) (*RetryableError, bool)

func NewRetryableError added in v0.0.80

func NewRetryableError(err error) RetryableError

func (RetryableError) Error added in v0.0.80

func (re RetryableError) Error() string

func (RetryableError) Unwrap added in v0.0.80

func (re RetryableError) Unwrap() error

Jump to

Keyboard shortcuts

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