errorex

package
v0.0.0-...-21d01d2 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2022 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Error

type Error struct {
	Message string
	Fields  []string
}

Error represents a custom validation error type. It contains a general validation message and a list of fields that are failed during validation.

func NewError

func NewError(msg string, fields ...string) *Error

NewError is the constructor of Error

func (*Error) Error

func (e *Error) Error() string

Implements error interface

type Errors

type Errors []Error

Errors conforms to the error protocol and aggregates all the validation errors at once into one error

func IsValidationErrors

func IsValidationErrors(err error) (Errors, bool)

IsValidationErrors returns true iff the root cause of the error is validation errors

func (*Errors) Add

func (e *Errors) Add(err *Error)

Add adds the given error to the list

func (*Errors) AddMany

func (e *Errors) AddMany(errs Errors)

AddMany adds the given errors to the list

func (*Errors) AddNew

func (e *Errors) AddNew(msg string, fields ...string)

AddNew adds the new error by the given fields

func (Errors) Error

func (e Errors) Error() string

Error implements the error protocol for Errors

Jump to

Keyboard shortcuts

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