drop

package
v0.0.0-...-e537141 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2023 License: GPL-3.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Exhaust

func Exhaust(t TryUntil, fn ErrorFn) (err error)

func InDirectory

func InDirectory(d Handler, path string, fn ErrorFn) (err error)

Types

type Dropper

type Dropper interface {
	Drop() error
}

Dropper is an interface that represents a resource that needs to be finalised and its finalisation can fail.

type Error

type Error struct {
	// The error that occurred when trying to close the resource.
	WhileDropping error
	// The error that occurred during the usage of a closable resource.
	Cause error
}

Error contains two errors that occur when an error occurs while using a Droppable resource (e.g. a closable file) and while trying to drop the resource an error occurs.

func (Error) Error

func (d Error) Error() (s string)

func (Error) Unwrap

func (d Error) Unwrap() (err error)

type ErrorFn

type ErrorFn func() error

func (ErrorFn) Drop

func (e ErrorFn) Drop() (err error)

Drop implements the Dropper interface for ErrorFn.

type ErrorFnHandler

type ErrorFnHandler interface {
	ErrorFnHandle(f ErrorFn) error
}

type Handler

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

Handler is used to handle the Drop method of resources implementing the Dropper interface.

func NewHandler

func NewHandler(tryUntil TryUntil) (c Handler)

NewHandler creates a DropHandler that wraps the tryUntil variable to be used for closing resources.

func (Handler) Handle

func (d Handler) Handle(err error, errFn ErrorFn) (Err error)

Handle attempts to close the resource using the tryUntil variable passed to the NewDropHandler function. If the error passed as the first argument is nit nil, the error returned by exhaustion of tryUntil will be wrapped in a DropError.

type InDir

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

func ChangeDirectory

func ChangeDirectory(path string) (in InDir, err error)

func (InDir) ChangeBack

func (id InDir) ChangeBack() (err error)

type Status

type Status bool
const (
	Continue Status = false
	Finished Status = true
)

type TryCreator

type TryCreator interface {
	CreateTry() TryUntil
}

type TryNTimes

type TryNTimes uint

func (TryNTimes) CreateTry

func (t TryNTimes) CreateTry() (tu TryUntil)

type TryNTimesImpl

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

func (*TryNTimesImpl) Try

func (t *TryNTimesImpl) Try(err error) (s Status)

type TryUntil

type TryUntil interface {
	Try(error) Status
}

Jump to

Keyboard shortcuts

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