errlist

package
v1.44.6 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2024 License: MPL-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var MaxErrorsToPrint = 1

MaxErrorsToPrint is the maximum number of errors to print if Verbose is false

View Source
var Verbose = false

Verbose controls whether the error list prints all errors or just the what MaxErrorsToPrint is set to

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 List

type List struct {
	List errinsrc.List `json:"list,omitempty"`
	// contains filtered or unexported fields
}

func Convert added in v1.8.0

func Convert(err error) *List

Convert attempts to convert known error types into an error list if it can't it returns nil

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 deprecated

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.

Deprecated: use Report instead

func (*List) AddRaw deprecated

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.

Deprecated: use Report instead

func (*List) Addf deprecated

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

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

Deprecated: use Report instead

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) ErrorList added in v1.8.0

func (l *List) ErrorList() []*errinsrc.ErrInSrc

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 deprecated

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.

Deprecated: use Report instead

func (*List) Report added in v1.8.0

func (l *List) Report(err error)

Report is a function that allows you to report an error into this list, without having to check for nil.

This function only supports error of types:

  • *List
  • *errinsrc.ErrInSrc
  • *scanner.Error

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

func (*List) SendToStream added in v1.8.0

func (l *List) SendToStream(stream interface {
	Send(*daemonpb.CommandMessage) error
}) error

SendToStream sends a GRPC command with this full errlist

If l is nil or empty, it sends a nil command allowing the client to know that there are no longer an error present

Jump to

Keyboard shortcuts

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