errutil

package
v0.0.0-...-c928bda Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2019 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package errutil provides utilities for working with errors.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CollectErrors

func CollectErrors(errs ...error) error

CollectErrors creates a MultiError from the given errors and returns its error representation (AsError). If there are no non-nil errors it returns nil, if there's exactly one error, it is returned and if there are more errors the MultiError is returned.

Types

type MultiError

type MultiError []error

MultiError is a slice of errors which itself implements the Error interface. A MultiError may contain nil errors.

func (MultiError) AsError

func (e MultiError) AsError() error

AsError returns nil if the normalised MultiError is empty, the only error if there's exactly one error and otherwise it returns the normalised version of itself.

func (MultiError) Error

func (e MultiError) Error() string

func (MultiError) Normalize

func (e MultiError) Normalize() MultiError

Normalize removes all instances of nil from the MultiError and flattens nested MultiError instances.

func (MultiError) Strings

func (e MultiError) Strings() []string

Strings returns a slice of all error strings in the MultiError. This does not use a normalized version of the MultiError.

Jump to

Keyboard shortcuts

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