Documentation
¶
Overview ¶
Package erg allows grouping errors into an error group.
Index ¶
- func Any(groupErr error) bool
- func Append(groupErr error, errs ...error) error
- func GetErrors(groupErr error) []error
- func New(kind erk.Kind, message string, errs ...error) error
- func NewAs(header error, errs ...error) error
- type ExportedGroup
- type ExportedGroupable
- type Group
- func (g *Group) Append(errs ...error) error
- func (g *Group) Error() string
- func (g *Group) Errors() []error
- func (g *Group) Export() erk.ExportedErkable
- func (g *Group) Header() error
- func (g *Group) IndentError(indentLevel string) string
- func (g *Group) Is(target error) bool
- func (g *Group) Kind() erk.Kind
- func (g *Group) Params() erk.Params
- func (g *Group) WithParams(params erk.Params) error
- type Groupable
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Any ¶
Any checks if there are any errors in the group. If groupErr is not Groupable, false is returned.
Types ¶
type ExportedGroup ¶
type ExportedGroup struct { *erk.ExportedError Header string `json:"header"` Errors []string `json:"errors"` }
ExportedGroup that can be used outside the erg package. A common use case is marshalling the error to JSON.
ExportedGroup satisfies the erk.ExportedErkable and the erg.ExportedGroupable interface.
func (*ExportedGroup) GroupErrors ¶
func (g *ExportedGroup) GroupErrors() []string
GroupErrors satisfies the ExportedGroupable interface.
func (*ExportedGroup) GroupHeader ¶
func (g *ExportedGroup) GroupHeader() string
GroupHeader satisfies the ExportedGroupable interface.
type ExportedGroupable ¶
ExportedGroupable is an exported readonly version of Groupable.
type Group ¶
type Group struct {
// contains filtered or unexported fields
}
Group of errors.
func (*Group) Error ¶
Error implements the error interface. It prints the header and list of errors.
func (*Group) Export ¶
func (g *Group) Export() erk.ExportedErkable
Export the group to an ExportedGroup.
func (*Group) IndentError ¶ added in v0.4.1
IndentError converts the error group to a string given the provided indentation.
func (*Group) Is ¶ added in v0.3.1
Is implements the Go 1.13+ Is interface for use with errors.Is.
Is first checks for a match against the group header, and then checks for a match against each error in the group.