errors

package
v0.0.32 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2021 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CallIfNil added in v0.0.30

func CallIfNil(err error, f func() error) error

CallIfNil calls f if err is nil

func FieldError

func FieldError(field string, msg string) error

FieldError creates an instance of BadFieldError without an index

func FieldErrorWithIndex

func FieldErrorWithIndex(index int, field string, msg string, data ...interface{}) error

FieldErrorWithIndex creates an instance of BadFieldError with an index

Types

type BadFieldError

type BadFieldError struct {
	Field string `json:"field,omitempty"`
	Msg   string `json:"msg"`
	Index *int   `json:"index,omitempty"`
	Data  interface{}
}

BadFieldError implements error. It describes an error relating to an object and/or field.

func BadFieldErrorFromStr

func BadFieldErrorFromStr(str string) *BadFieldError

BadFieldErrorFromStr attempts to convert a string to a BadFieldError. It expects the string to match the BadFieldError.Error output.

func (*BadFieldError) Error

func (b *BadFieldError) Error() string

func (*BadFieldError) Is

func (b *BadFieldError) Is(target error) bool

type ReqError

type ReqError struct {
	Code     string
	HttpCode int
	Msg      string
	Field    string
}

ReqError describes an error consumable by http services.

func ReqErr

func ReqErr(httpCode int, code, field, msg string) *ReqError

ReqErr creates ReqError

func ReqErrorFromStr

func ReqErrorFromStr(str string) *ReqError

ReqErrorFromStr attempts to convert a string to a ReqError. It expects the string to match the ReqError.Error output. Never returns an error even on failure.

func (*ReqError) Error

func (s *ReqError) Error() string

func (*ReqError) IsSet

func (s *ReqError) IsSet() bool

IsSet returns true if code, http code and msg fields are set

func (ReqError) String added in v0.0.30

func (s ReqError) String() string

Jump to

Keyboard shortcuts

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