multierr

package
v0.2.13 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2025 License: MIT Imports: 5 Imported by: 0

README

Package multierr

multiple error.

Usage

package main

import (
	"fmt"
	"log"

	"github.com/QisFj/godry/multierr"
)

func main() {
	errs := multierr.New(func(err error) error {
		return fmt.Errorf("-> %w", err)
	}, nil)
	for i := 0; i < 6; i++ {
		var err error
		if i%2 == 0 {
			err = fmt.Errorf("error-%d", i+1)
		}
		errs.AppendOnlyNotNil(err)
	}
	log.Printf("err: %s\n", errs.Error())
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatterList

func FormatterList(errs []error) string

FormatterList is the default Formatter

Types

type ErrWrapper

type ErrWrapper func(err error) error

type Errs

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

func New

func New(wrapper ErrWrapper, formatter Formatter) *Errs

func (*Errs) Append

func (errs *Errs) Append(err error)

func (*Errs) AppendOnlyNotNil

func (errs *Errs) AppendOnlyNotNil(err error)

func (*Errs) Appendf

func (errs *Errs) Appendf(format string, v ...interface{})

func (*Errs) Error

func (errs *Errs) Error() error

func (*Errs) IsNil

func (errs *Errs) IsNil() bool

type Formatter

type Formatter func(errs []error) string

Jump to

Keyboard shortcuts

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