errutils

package
v0.0.16 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

README

write readme for errutils package

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FmtError deprecated

func FmtError(f string, v ...any) error

FmtError formats an error message using a format string and optional values, and returns it as an error object.

It takes a format string f and variadic arguments v, and uses them to construct the error message by calling fmt.Sprintf function. The resulting error message is then wrapped into an error object using errors.New.

Example:

err := FmtError("Invalid input: %s", userInput)
if err != nil {
	log.Println(err)
}

Deprecated: In favour of fmt.Errorf(...) instead @param f The format string specifying the error message. @param v Optional values to be inserted into the format string. @returns An error object containing the formatted error message.

Types

type MultiError added in v0.0.15

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

func NewMultiErr added in v0.0.15

func NewMultiErr(err error) (multiErr *MultiError)

NewMultiErr creates a new MultiError and adds the given error to it.

func (*MultiError) Add added in v0.0.15

func (m *MultiError) Add(err error)

Add adds an error to the MultiError. If the error is nil, it is not added.

func (*MultiError) Error added in v0.0.15

func (m *MultiError) Error() string

Error function implements the error.Error function of the error interface

func (*MultiError) GetAll added in v0.0.15

func (m *MultiError) GetAll() (errs []error)

GetAll returns all the errors in the MultiError.

func (*MultiError) HasError added in v0.0.15

func (m *MultiError) HasError(err error) bool

HasError will return true if the MultiError has any errors of the specified type

Jump to

Keyboard shortcuts

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