errorz

package
v2.0.48 Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2024 License: Apache-2.0 Imports: 3 Imported by: 50

Documentation

Index

Constants

View Source
const (
	NotFoundCode    string = "NOT_FOUND"
	NotFoundMessage string = "The resource requested was not found or is no longer available"
	NotFoundStatus  int    = http.StatusNotFound

	UnhandledCode    string = "UNHANDLED"
	UnhandledMessage string = "An unhandled error occurred"
	UnhandledStatus  int    = http.StatusInternalServerError

	InvalidFieldCode    string = "INVALID_FIELD"
	InvalidFieldMessage string = "The field contains an invalid value"
	InvalidFieldStatus  int    = http.StatusBadRequest

	EntityCanNotBeDeletedCode    string = "ENTITY_CAN_NOT_BE_DELETED"
	EntityCanNotBeDeletedMessage string = "The entity requested for delete can not be deleted"
	EntityCanNotBeDeletedStatus         = http.StatusBadRequest

	EntityCanNotBeUpdatedCode    string = "ENTITY_CAN_NOT_BE_UPDATED"
	EntityCanNotBeUpdatedMessage string = "The entity requested for update can not be updated"
	EntityCanNotBeUpdatedStatus         = http.StatusBadRequest

	CouldNotValidateCode    string = "COULD_NOT_VALIDATE"
	CouldNotValidateMessage string = "The supplied request contains an invalid document or no valid accept content were available, see cause"
	CouldNotValidateStatus  int    = http.StatusBadRequest

	UnauthorizedCode    string = "UNAUTHORIZED"
	UnauthorizedMessage string = "The request could not be completed. The session is not authorized or the credentials are invalid"
	UnauthorizedStatus  int    = http.StatusUnauthorized
)
View Source
const (
	InvalidFilterCode    string = "INVALID_FILTER"
	InvalidFilterMessage string = "The filter query supplied is invalid"

	InvalidFilterStatus int = httpStatusInvalidFilter

	InvalidPaginationCode    string = "INVALID_PAGINATION"
	InvalidPaginationMessage string = "The pagination properties provided are invalid"
	InvalidPaginationStatus  int    = http.StatusBadRequest

	InvalidSortCode    string = "INVALID_SORT_IDENTIFIER"
	InvalidSortMessage string = "The sort order supplied is invalid"
	InvalidSortStatus  int    = http.StatusBadRequest
)

specific

Variables

This section is empty.

Functions

This section is empty.

Types

type ApiError

type ApiError struct {
	Code        string `json:"code"`
	Message     string `json:"message"`
	Status      int    `json:"-"`
	Cause       error  `json:"cause"`
	AppendCause bool   `json:"-"`
}

func NewCouldNotValidate

func NewCouldNotValidate(err error) *ApiError

func NewEntityCanNotBeDeleted

func NewEntityCanNotBeDeleted() *ApiError

func NewEntityCanNotBeDeletedFrom

func NewEntityCanNotBeDeletedFrom(err error) *ApiError

func NewEntityCanNotBeUpdatedFrom

func NewEntityCanNotBeUpdatedFrom(err error) *ApiError

func NewFieldApiError

func NewFieldApiError(fieldError *FieldError) *ApiError

func NewInvalidFilter

func NewInvalidFilter(cause error) *ApiError

func NewInvalidPagination

func NewInvalidPagination(err error) *ApiError

func NewInvalidSort

func NewInvalidSort(err error) *ApiError

func NewNotFound

func NewNotFound() *ApiError

func NewUnauthorized

func NewUnauthorized() *ApiError

func NewUnhandled

func NewUnhandled(cause error) *ApiError

func (ApiError) Error

func (e ApiError) Error() string

type ErrorHolder

type ErrorHolder interface {
	GetError() error
	SetError(error) bool
	HasError() bool
}

type ErrorHolderImpl

type ErrorHolderImpl struct {
	Err error
}

func (*ErrorHolderImpl) GetError

func (holder *ErrorHolderImpl) GetError() error

func (*ErrorHolderImpl) HasError

func (holder *ErrorHolderImpl) HasError() bool

func (*ErrorHolderImpl) SetError

func (holder *ErrorHolderImpl) SetError(err error) bool

type FieldError

type FieldError struct {
	Reason     string      `json:"message"`
	FieldName  string      `json:"field"`
	FieldValue interface{} `json:"value"`
}

func NewFieldError

func NewFieldError(reason, name string, value interface{}) *FieldError

func (FieldError) Error

func (fe FieldError) Error() string

type MultipleErrors

type MultipleErrors []error

func (MultipleErrors) Error

func (e MultipleErrors) Error() string

func (MultipleErrors) ToError

func (e MultipleErrors) ToError() error

Jump to

Keyboard shortcuts

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