Help us shape the future of Go! Take the 2026 Go Developer Survey

errbuf

package module
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2025 License: MIT Imports: 1 Imported by: 0

README

errbuf

Simple module for go applications, which allows to collect errors into a buffer.

Documentation

Overview

Package errbuf contains errors buffer, which allows to collect errors before processing them. In addition this buffer can hold warnings, which are the same error type, but can be accessed via their own methods and processed accordingly. This buffer is goroutine safe.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BufferedError

type BufferedError struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

BufferedError represents cache to collect errors during the process before fail. Also allows to collect not critical warnings which can be just reported instead.

func NewBufferFromError

func NewBufferFromError(err error) *BufferedError

NewBufferFromError creates new BufferedError from the given error.

func NewBufferFromWarning

func NewBufferFromWarning(err error) *BufferedError

NewBufferFromWarning creates new [BuffereError] and adds given error to warnings.

func NewErrorsBuffer

func NewErrorsBuffer() *BufferedError

NewErrorsBuffer creates empty BufferedError.

func (*BufferedError) Add

func (buf *BufferedError) Add(err error)

Add adds given error to the errors buffer. No-op if error is nil.

func (*BufferedError) Err

func (buf *BufferedError) Err() error

Err returns nil if error buffer is empty.

func (*BufferedError) Error

func (buf *BufferedError) Error() string

Error formats errors in the buffer into the string.

func (*BufferedError) ShouldWarn

func (buf *BufferedError) ShouldWarn() bool

ShouldWarn returns true if warnings buffer is not empty.

func (*BufferedError) Unwrap

func (buf *BufferedError) Unwrap() []error

Unwrap returns copy of the buffer errors.

func (*BufferedError) Warn

func (buf *BufferedError) Warn(err error)

Warn adds given error to the warnings buffer. No-op if error is nil.

func (*BufferedError) Warning

func (buf *BufferedError) Warning() string

Warning formats warnings in the buffer into the string.

Jump to

Keyboard shortcuts

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