error

package
v0.0.0-...-60f5d5a Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateInvalidError

func CreateInvalidError(errorCodeSuffix string, message string, args ...any) error

Dynamic error generation functions

func HasErrorCode

func HasErrorCode(err error, c ErrorCode) bool

func IsError

func IsError(e error) bool

func NewHeaderError

func NewHeaderError(message string, args ...any) error

func NewInternalError

func NewInternalError(message string, args ...any) error

func NewInvalidActionError

func NewInvalidActionError(message string) error

func NewInvalidDataError

func NewInvalidDataError(message string, args ...any) error

func NewInvalidJSONError

func NewInvalidJSONError(resultErrors []gojsonschema.ResultError) error

func NewMalformedError

func NewMalformedError() error

func NewNotFoundError

func NewNotFoundError(resource string, id string) error

func NewParamError

func NewParamError(message string, args ...any) error

func NewUnauthenticatedError

func NewUnauthenticatedError(message string, args ...any) error

func NewUnauthorizedError

func NewUnauthorizedError() error

func NewUnavailableError

func NewUnavailableError() error

func ProcessParamError

func ProcessParamError(err error) error

Types

type Error

type Error struct {
	HttpStatusCode         int                     `json:"-"`
	ErrorCode              ErrorCode               `json:"code"`
	Message                string                  `json:"message"`
	SchemaValidationErrors []SchemaValidationError `json:"validationErrors,omitempty"`
	// The following are intentionally not included in any public response
	LogLevel   logger.Level
	LogMessage string
}

func ToError

func ToError(e error) (Error, error)

func ToErrors

func ToErrors(errs ...error) ([]Error, error)

func (Error) Error

func (e Error) Error() string

type ErrorCode

type ErrorCode string
const (
	InvalidAction   ErrorCode = "invalid_action"
	InvalidJSON     ErrorCode = "invalid_json"
	InvalidData     ErrorCode = "invalid_data"
	InvalidHeader   ErrorCode = "invalid_header"
	InvalidParam    ErrorCode = "invalid_parameter"
	NotFound        ErrorCode = "resource_not_found"
	Unauthorized    ErrorCode = "unauthorized"
	Unauthenticated ErrorCode = "unauthenticated"
	Unavailable     ErrorCode = "unavailable"
	Malformed       ErrorCode = "malformed"
	Internal        ErrorCode = "internal_error"
)

func CreateErrorCode

func CreateErrorCode(errorType string, field string) ErrorCode

type SchemaValidationError

type SchemaValidationError struct {
	DataPath string `json:"dataPath"`
	Message  string `json:"message"`
}

func (SchemaValidationError) GetField

func (sve SchemaValidationError) GetField() string

Jump to

Keyboard shortcuts

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