errors

package
v0.0.45 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2021 License: MIT Imports: 4 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrorHandlers = []func(error){
	func() func(err error) {
		limiter := rate.NewLimiter(rate.Every(time.Millisecond), 1)
		return func(err error) {

			_ = limiter.Wait(context.Background())
		}
	}(),
}

ErrorHandlers is a list of functions which will be invoked when a nonreturnable error occurs. should be packaged up into a testable and reusable object.

Functions

func HandleError

func HandleError(err error)

HandlerError is a method to invoke when a non-user facing piece of code cannot return an error and needs to indicate it has been ignored. Invoking this method is preferable to logging the error - the default behavior is to log but the errors may be sent to a remote server for analysis.

Types

type Aggregate

type Aggregate interface {
	error
	Errors() []error
	Is(error) bool
}

func NewAggregate

func NewAggregate(errlist []error) Aggregate

NewAggregate converts a slice of errors into an Aggregate interface, which is itself an implementation of the error interface. If the slice is empty, this returns nil. It will check if any of the element of input error list is nil, to avoid nil pointer panic when call Error().

Jump to

Keyboard shortcuts

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