errs

package
v0.0.0-...-20e485d Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package errs provides types and support related to web error functionality.

Index

Constants

This section is empty.

Variables

View Source
var (
	OK                 = errs.OK
	NoContent          = errs.OK
	Canceled           = errs.Canceled
	Unknown            = errs.Unknown
	InvalidArgument    = errs.InvalidArgument
	DeadlineExceeded   = errs.DeadlineExceeded
	NotFound           = errs.NotFound
	AlreadyExists      = errs.AlreadyExists
	PermissionDenied   = errs.PermissionDenied
	ResourceExhausted  = errs.ResourceExhausted
	FailedPrecondition = errs.FailedPrecondition
	Aborted            = errs.Aborted
	OutOfRange         = errs.OutOfRange
	Unimplemented      = errs.Unimplemented
	Internal           = errs.Internal
	Unavailable        = errs.Unavailable
	DataLoss           = errs.DataLoss
	Unauthenticated    = errs.Unauthenticated
)

This set of variables exist so I can move APP layer code from the service project over without the need to refactor.

Functions

func Check

func Check(val any) error

Check validates the provided model against it's declared tags.

func IsFieldErrors

func IsFieldErrors(err error) bool

IsFieldErrors checks if an error of type FieldErrors exists.

func New

func New(code errs.ErrCode, err error) *errs.Error

New constructs an encore error based on an app error.

func NewFieldsError

func NewFieldsError(field string, err error) error

NewFieldsError creates an fields error.

func NewResponse

func NewResponse(code errs.ErrCode, err error) middleware.Response

NewResponse constructs an encore middleware response with a Go error.

func NewResponsef

func NewResponsef(code errs.ErrCode, format string, v ...any) middleware.Response

NewResponsef constructs an encore middleware response with a message.

func Newf

func Newf(code errs.ErrCode, format string, v ...any) *errs.Error

Newf constructs an encore error based on a error message.

Types

type FieldError

type FieldError struct {
	Field string `json:"field"`
	Err   string `json:"error"`
}

FieldError is used to indicate an error with a specific request field.

type FieldErrors

type FieldErrors []FieldError

FieldErrors represents a collection of field errors.

func GetFieldErrors

func GetFieldErrors(err error) FieldErrors

GetFieldErrors returns a copy of the FieldErrors pointer.

func (FieldErrors) Error

func (fe FieldErrors) Error() string

Error implements the error interface.

func (FieldErrors) Fields

func (fe FieldErrors) Fields() map[string]string

Fields returns the fields that failed validation

Jump to

Keyboard shortcuts

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