errlist

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: May 27, 2022 License: MPL-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Print

func Print(w io.Writer, err error)

Print is a utility function that prints a list of errors to w, one error per line, if the err parameter is an ErrorList. Otherwise it prints the err string.

Types

type Bailout

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

Bailout is a sentinel type for panics that indicate to immediately stop processing because too many errors have been found. It can conveniently be handled by HandleBailout.

type List

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

func New

func New(fset *token.FileSet) *List

func (*List) Abort

func (l *List) Abort()

Abort aborts early if there is an error in the list.

func (*List) Add

func (l *List) Add(pos token.Pos, msg string)

Add adds an error to the list.

If too many errors have been added it panics with a Bailout value to abort processing. Use HandleBailout to conveniently handle this.

func (*List) AddRaw

func (l *List) AddRaw(err *scanner.Error)

AddRaw adds a raw *scanner.Error to the list.

If too many errors have been added it panics with a Bailout value to abort processing. Use HandleBailout to conveniently handle this.

func (*List) Addf

func (l *List) Addf(pos token.Pos, format string, args ...interface{})

Addf is equivalent to Add(pos, fmt.Sprintf(format, args...))

func (*List) Err

func (l *List) Err() error

Err returns an error equivalent to this error list. If the list is empty, Err returns nil.

func (*List) Error

func (l *List) Error() string

Error implements the error interface.

func (*List) HandleBailout

func (l *List) HandleBailout(err *error)

HandleBailout handles bailouts raised by (*List).Add and family when too many errors have been found.

func (*List) Len

func (l *List) Len() int

func (*List) MakeRelative

func (l *List) MakeRelative(root, relwd string)

MakeRelative rewrites the errors by making filenames within the app root relative to the relwd (which must be a relative path within the root).

func (*List) Merge

func (l *List) Merge(other *List)

Merge merges another list into this one. The token.FileSet in use must be the same one as this one, or else it panics.

func (*List) Sort

func (l *List) Sort()

Sort sorts the error list.

Jump to

Keyboard shortcuts

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