errors

package
v0.0.0-...-c864ae1 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2023 License: BSD-2-Clause, BSD-3-Clause, MIT Imports: 4 Imported by: 0

Documentation

Overview

Package errors offers an extension of functionality to the default golang errors package.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CompositeError

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

CompositeError allows a number of errors to be collected together and treated as if they were a single error.

func New

func New(text string) *CompositeError

New returns a new CompositeError. The text parameter supplied is used as a prefix when reporting a list of errors.

func (*CompositeError) Add

func (ce *CompositeError) Add(newError error)

Add includes newError as one of the sub-errors of a CompositeError

Example
newComposite := New("error prefix")
newComposite.Add(errors.New("first error"))
newComposite.Add(errors.New("second error"))
fmt.Printf("%v", newComposite)
Output:

error prefix, composed of: [
	first error
	second error
]

func (*CompositeError) AddMessage

func (ce *CompositeError) AddMessage(message string)

Add combines the supplied message as a new built-in error to the array of sub-errors of a CompositeError

func (*CompositeError) Error

func (ce *CompositeError) Error() string

Error conforms to the built-in interface type for representing an error condition over a composed set of errors.

func (*CompositeError) Initialise

func (ce *CompositeError) Initialise(text string) *CompositeError

func (*CompositeError) MarshalJSON

func (ce *CompositeError) MarshalJSON() ([]byte, error)

MarshalJSON conforms to the built-in interface type for encoding a composed set of errors as json string array.

func (*CompositeError) Size

func (ce *CompositeError) Size() int

ColumnAndRowSize returns the number of sub-errors in a CompositeError. It counts only directly accessible sub-errors (no nesting).

func (*CompositeError) SubError

func (ce *CompositeError) SubError(index int) error

SubError returns the sub-error at the given array index of a CompositeError

Jump to

Keyboard shortcuts

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