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 ¶
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.