aggregator

package
v0.0.0-...-777877a Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Aggregator

type Aggregator struct {
	Subject string
	Errors  []error
}

func New

func New(s string) *Aggregator

func (*Aggregator) CheckAndAdd

func (a *Aggregator) CheckAndAdd(err error) bool

CheckAndAdd appends the given error to the Aggregator's error list if it is not nil. Returns false if the error was added, true otherwise.

This method is intended to be used with nil checks, e.g.:

if data, err := someFunc(); a.CheckAndAdd(err) {
	// No error, do something with data
}

func (*Aggregator) CheckPredicateAndAdd

func (a *Aggregator) CheckPredicateAndAdd(predicate bool, errorMessage string) bool

CheckPredicateAndAdd evaluates the given predicate and, if it is false, appends the given error message to the Aggregator's error list. Returns the value of the predicate.

Example:

if a.CheckPredicateAndAdd(data != "", "no data found") {
	// Data is not empty, do something with it
}

func (*Aggregator) Error

func (a *Aggregator) Error() string

Error returns a string with all errors concatenated, joined by a semicolon.

func (*Aggregator) ErrorOrNil

func (a *Aggregator) ErrorOrNil() error

ErrorOrNil returns any errors reported, or nil if none.

Jump to

Keyboard shortcuts

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