errutil

package
v1.2.14 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2023 License: MIT Imports: 5 Imported by: 9

Documentation

Overview

Package errutil offers various types and funcs to help with some common ways of using errors.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ErrMap

type ErrMap map[string][]error

ErrMap is a type that maps a string to a list of errors. It is useful for the case where you want to return more than one error and want to group them in some way for reporting. Each map entry represents a category for which some errors have been found.

func NewErrMap

func NewErrMap() *ErrMap

NewErrMap returns a new instance of an ErrMap

func (*ErrMap) AddError

func (em *ErrMap) AddError(cat string, err error)

AddError adds the error to the category slice

func (ErrMap) CategorySummary

func (em ErrMap) CategorySummary(cat string) string

CategorySummary returns a summary description of the errors in the ErrMap for the given category

func (ErrMap) CountErrors

func (em ErrMap) CountErrors() (int, int)

CountErrors counts the total number of errors and the number of categories (in that order)

func (ErrMap) HasErrors added in v1.2.0

func (em ErrMap) HasErrors() bool

HasErrors returns true if there are any errors in the map, false otherwise.

func (ErrMap) Keys

func (em ErrMap) Keys() []string

Keys returns the keys to the ErrMap (the categories)

func (ErrMap) Matches added in v1.1.0

func (em ErrMap) Matches(other ErrMap) error

Matches returns an error if the two ErrMaps differ, nil otherwise

func (ErrMap) Report

func (em ErrMap) Report(w io.Writer, name string)

Report writes the error map out to the writer

func (ErrMap) Summary

func (em ErrMap) Summary() string

Summary returns a summary description of the ErrMap

Jump to

Keyboard shortcuts

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