errors

package
v1.1.8 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2020 License: BSD-2-Clause Imports: 6 Imported by: 1

Documentation

Overview

Package errors provides grouped errors.

Index

Examples

Constants

This section is empty.

Variables

View Source
var New = errors.New

New creates a new error

Functions

This section is empty.

Types

type Group

type Group struct {
	// contains filtered or unexported fields
}

Group defines a set errors

func NewGroup

func NewGroup(prefix string) *Group

NewGroup given a prefix will return an Group with the given prefix. Group formats errors like so;

{prefix}: {err msg}
Example
g := NewGroup("group1").Add(
	NewGroup("group2").Add(
		NewGroup("group3").Add(New("group before this")).Add(New("space before this")).Add(New(`space before this
carriage return before this`)),
	).New(`group before this
carriage return before this
carriage return before this
carriage return before this `),
)

fmt.Println(g.Error())
Output:

group1: group2: group3: group before this
                        space before this
                        space before this
                      ⮎ carriage return before this
group1: group2: group before this
              ⮎ carriage return before this
              ⮎ carriage return before this
              ⮎ carriage return before this

func (*Group) Add

func (g *Group) Add(err error) *Group

Add adds a given error to the Group

func (*Group) Error

func (g *Group) Error() string

Error implements the error interface

func (*Group) Errored

func (g *Group) Errored() bool

Errored returns true if an error has been added and false if no errors have been added.

func (*Group) New

func (g *Group) New(s string) *Group

New creates a new error and adds the new error to the Group

func (*Group) Newf

func (g *Group) Newf(format string, a ...interface{}) *Group

Newf creates a new error with formatting and adds the new error to the Group

Jump to

Keyboard shortcuts

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