Documentation
¶
Index ¶
- Constants
- func IsAlreadyExistsError(e error) bool
- func IsContentTooLargeError(e error) bool
- func IsFailedPreconditionError(e error) bool
- func IsInternalError(e error) bool
- func IsInvalidArgumentError(e error) bool
- func IsNotFoundError(e error) bool
- func IsOutOfRange(e error) bool
- func IsPermissionDeniedError(e error) bool
- func IsUnauthenticatedError(e error) bool
- func IsUnimplemented(e error) bool
- func OutputErrsMatchInputLength(errs []error, inputLength int, err error) ([]error, error)
- func PanicsWithCliniaError(t *testing.T, expected CliniaError, f func())
- type CliniaError
- func AlreadyExistsError(error string) CliniaError
- func AlreadyExistsErrorf(format string, args ...interface{}) CliniaError
- func ContentTooLargeError(error string) CliniaError
- func ContentTooLargeErrorf(format string, args ...interface{}) CliniaError
- func FailedPreconditionError(error string) CliniaError
- func FailedPreconditionErrorf(format string, args ...interface{}) CliniaError
- func InternalError(error string) CliniaError
- func InternalErrorf(format string, args ...interface{}) CliniaError
- func InvalidArgumentError(error string) CliniaError
- func InvalidArgumentErrorf(format string, args ...interface{}) CliniaError
- func IsCliniaError(e error) (*CliniaError, bool)
- func NewAlreadyExistsError(message string) CliniaErrordeprecated
- func NewCliniaErrorFromMessage(msg string) (*CliniaError, error)
- func NewCliniaInternalErrorFromError(err error) CliniaError
- func NewEnumOutOfRangeError(actual string, expectedOneOf []string, enumName string) CliniaError
- func NewFailedPreconditionError(message string) CliniaErrordeprecated
- func NewInternalError(e error) CliniaErrordeprecated
- func NewMultipleOutOfRangeError(actual []string, expectedOneOf []string) CliniaError
- func NewNotFoundError(msg string, err error) CliniaErrordeprecated
- func NewSingleOutOfRangeError(actual string, expectedOneOf []string) CliniaError
- func NotFoundError(error string) CliniaError
- func NotFoundErrorf(format string, args ...interface{}) CliniaError
- func OutOfRangeError(error string) CliniaError
- func OutOfRangeErrorf(format string, args ...interface{}) CliniaError
- func PermissionDeniedError(error string) CliniaError
- func PermissionDeniedErrorf(format string, args ...interface{}) CliniaError
- func UnauthenticatedError(error string) CliniaError
- func UnauthenticatedErrorf(format string, args ...interface{}) CliniaError
- func UnimplementedError(error string) CliniaError
- func UnimplementedErrorf(format string, args ...interface{}) CliniaError
- type CliniaErrors
- type ErrorType
- type RetryableError
Constants ¶
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") ErrorTypeContentTooLarge = ErrorType("CONTENT_TOO_LARGE") )
Variables ¶
This section is empty.
Functions ¶
func IsAlreadyExistsError ¶ added in v0.0.25
func IsContentTooLargeError ¶ added in v0.0.89
func IsInternalError ¶ added in v0.0.25
func IsInvalidArgumentError ¶ added in v0.0.37
func IsNotFoundError ¶
func IsOutOfRange ¶ added in v0.0.37
func IsPermissionDeniedError ¶ added in v0.0.43
func IsUnauthenticatedError ¶ added in v0.0.43
func IsUnimplemented ¶ added in v0.0.37
func OutputErrsMatchInputLength ¶ added in v0.0.125
This is to reduce the boilerplate check, it checks the length of the error slice with the expected inputLength. Also takes in an error since the usual pattern for batch function is to look like `func(ctx context.Context, inputs []any) ([]any, []error, error)` This takes the priority of if : - There is an error, return the error back - There is no error but the length of the errs slice mismatch the inputLength, return a preformatted error - Return nil if no problem are found
outputs, errs, err := funcThatProcess(ctx, inputs)
if err != nil {
return nil, make(error[], len(inputs)), err
}
if len(errs) != len(inputs) {
return nil, make(error[], len(inputs)), errorx.InternalErrorf("inputs mismatch")
}
return outputs, errs, nil
and we can replace this with:
outputs, errs, err := funcThatProcess(ctx, inputs)
if errs, err := OutputErrsMatchInputLength(errs, len(inputs), err); err != nil {
return nil, errs, err
}
return outputs, errs, nil
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 `json:"-"`
// List of errors that caused the error if applicable
Details []CliniaError
}
func AlreadyExistsError ¶ added in v0.0.118
func AlreadyExistsError(error string) CliniaError
AlreadyExistsError creates a CliniaError with type ErrorTypeAlreadyExists and a message
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 ContentTooLargeError ¶ added in v0.0.118
func ContentTooLargeError(error string) CliniaError
ContentTooLargeError creates a CliniaError with type ErrorTypeContentTooLarge and a message
func ContentTooLargeErrorf ¶ added in v0.0.89
func ContentTooLargeErrorf(format string, args ...interface{}) CliniaError
ContentTooLargeErrorf creates a CliniaError with type ErrorTypeContentTooLarge and a formatted message
func FailedPreconditionError ¶ added in v0.0.118
func FailedPreconditionError(error string) CliniaError
FailedPreconditionError creates a CliniaError with type ErrorTypeFailedPrecondition and a 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 InternalError ¶ added in v0.0.118
func InternalError(error string) CliniaError
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 InvalidArgumentError ¶ added in v0.0.118
func InvalidArgumentError(error string) CliniaError
InvalidArgumentError creates a CliniaError with type ErrorTypeInvalidArgument and a 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 NewCliniaInternalErrorFromError ¶ added in v0.0.133
func NewCliniaInternalErrorFromError(err error) CliniaError
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 NotFoundError ¶ added in v0.0.118
func NotFoundError(error string) CliniaError
NotFoundError creates a CliniaError with type ErrorTypeNotFound and a message
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 OutOfRangeError ¶ added in v0.0.118
func OutOfRangeError(error string) CliniaError
OutOfRangeError creates a CliniaError with type ErrorTypeOutOfRange and a 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 PermissionDeniedError ¶ added in v0.0.118
func PermissionDeniedError(error string) CliniaError
PermissionDeniedError creates a CliniaError with type ErrorTypePermissionDenied and a 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 UnauthenticatedError ¶ added in v0.0.118
func UnauthenticatedError(error string) CliniaError
UnauthenticatedError creates a CliniaError with type ErrorTypeUnauthenticated and a 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 UnimplementedError ¶ added in v0.0.118
func UnimplementedError(error string) CliniaError
UnimplementedError creates a CliniaError with type ErrorTypeUnimplemented and a 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 (e *CliniaError) AsRetryableError() RetryableError
func (CliniaError) Error ¶
func (e CliniaError) Error() string
func (*CliniaError) IsRetryable ¶ added in v0.0.80
func (e *CliniaError) IsRetryable() bool
func (*CliniaError) WithDetails ¶ added in v0.0.66
func (e *CliniaError) WithDetails(details ...CliniaError) CliniaError
WithDetails allows to attach multiple errors to the error
func (*CliniaError) WithErrorDetails ¶ added in v0.0.133
func (e *CliniaError) WithErrorDetails(details ...error) CliniaError
WithDetails allows to attach multiple errors to the error
type CliniaErrors ¶ added in v0.0.133
type CliniaErrors []*CliniaError
func CliniaErrorsFromCliniaErrorSlice ¶ added in v0.0.133
func CliniaErrorsFromCliniaErrorSlice(errs []CliniaError) CliniaErrors
func CliniaErrorsFromErrorSlice ¶ added in v0.0.133
func CliniaErrorsFromErrorSlice(errs []error) CliniaErrors
func (CliniaErrors) AsErrors ¶ added in v0.0.133
func (cErrs CliniaErrors) AsErrors() []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