errorx

package
v0.0.19 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2023 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrorType_name = map[int]string{
		0: "UNSPECIFIED",
		1: "INTERNAL",
		2: "OUT_OF_RANGE",
		3: "UNSUPPORTED",
		4: "NOT_FOUND",
		5: "ALREADY_EXISTS",
		6: "INVALID_FORMAT",
		7: "FAILED_PRECONDITION",
	}
	ErrorType_value = map[string]int{
		"UNSPECIFIED":         0,
		"INTERNAL":            1,
		"OUT_OF_RANGE":        2,
		"UNSUPPORTED":         3,
		"NOT_FOUND":           4,
		"ALREADY_EXISTS":      5,
		"INVALID_FORMAT":      6,
		"FAILED_PRECONDITION": 7,
	}
)

TODO: update below

Functions

func IsFailedPreconditionError

func IsFailedPreconditionError(e error) bool

func IsNotFoundError

func IsNotFoundError(e error) bool

Types

type CliniaError

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

	OriginalError error // Not returned to clients
}

func IsCliniaError

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

func NewAlreadyExistsError

func NewAlreadyExistsError(message string) CliniaError

func NewCliniaErrorFromMessage

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

func NewEnumOutOfRangeError

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

func NewFailedPreconditionError

func NewFailedPreconditionError(message string) CliniaError

func NewInvalidFormatError

func NewInvalidFormatError(message string) CliniaError

func NewMultipleOutOfRangeError

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

func NewNotFoundError

func NewNotFoundError(msg string, err error) CliniaError

func NewSingleOutOfRangeError

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

func NewUnsupportedError

func NewUnsupportedError(message string) CliniaError

func NewUnsupportedTypeError

func NewUnsupportedTypeError[T1 any, T2 any](actual T1, expected T2) CliniaError

func NewUnsupportedValueError

func NewUnsupportedValueError(actual string, expected string) CliniaError

func (CliniaError) Error

func (e CliniaError) Error() string

type CliniaRetryableError

type CliniaRetryableError = CliniaError

func NewInternalError

func NewInternalError(e error) CliniaRetryableError

type ErrorType

type ErrorType int
const (
	// The Invalid type should not be used, only useful to assert whether or not an error is an MdmError during cast
	ErrorTypeUnspecified ErrorType = iota
	ErrorTypeInternal
	ErrorTypeOutOfRange
	ErrorTypeUnsupported // Bad request
	ErrorTypeNotFound
	ErrorTypeAlreadyExists // Conflict
	// Map to 422
	ErrorTypeInvalidFormat
	// Map to 400
	ErrorTypeFailedPrecondition
)

func ParseErrorType

func ParseErrorType(s string) (ErrorType, error)

func (ErrorType) MarshalJSON

func (e ErrorType) MarshalJSON() ([]byte, error)

func (ErrorType) String

func (u ErrorType) String() string

func (*ErrorType) UnmarshalJSON

func (e *ErrorType) UnmarshalJSON(data []byte) (err error)

Jump to

Keyboard shortcuts

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