Documentation
¶
Index ¶
- func CallOnNilErr(err error, f func() error) error
- func FieldError(field string, msg string) error
- func FieldErrorWithIndex(index int, field string, msg string, data ...interface{}) error
- func IsReqError(target error) bool
- func WrongFieldValueMsg(expectedType string, actual interface{}) string
- type BadFieldError
- type ReqError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CallOnNilErr ¶
CallOnNilErr calls f if err is nil
func FieldError ¶
FieldError creates an instance of BadFieldError without an index
func FieldErrorWithIndex ¶
FieldErrorWithIndex creates an instance of BadFieldError with an index
func IsReqError ¶
func WrongFieldValueMsg ¶
WrongFieldValueMsg generates a message to indicate an unexpected field value type
Types ¶
type BadFieldError ¶
BadFieldError implements error. It describes an error relating to an object and/or field. It outputs the example format: `field:id, msg:some error message about id, index:1`
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 ¶
ReqError describes an error consumable by http services.
func ReqErr ¶
ReqErr creates ReqError It outputs the example format: `msg:'some error message', httpCode:'400', code:'err_mempool, field:'id'`
func ReqErrorFromStr ¶
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.