errors

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2020 License: MIT Imports: 2 Imported by: 15

README

go-errors

Just a collection of go error implementations.

Documentation

Overview

Package errors provides some convenient error implementations.

Index

Constants

This section is empty.

Variables

View Source
var MultiErrorPrefix = "Multiple errors occured:\n"

MultiErrorPrefix will be prepended to the Error() output of any MultiError, that actually consists of multiple errors. You can overwrite this if you want to.

Functions

func As

func As(err error, target interface{}) bool

As calls standard API errors.As.

func Errorf

func Errorf(format string, args ...interface{}) error

Errorf calls fmt.Errorf.

func Is

func Is(err, target error) bool

Is calls standard API errors.Is.

func IsMultiError

func IsMultiError(err error) bool

IsMultiError returns true if the given error was a MultiError.

func New

func New(text string) error

New returns an error that formats as the given text.

func NewMultiError

func NewMultiError(errors ...error) error

NewMultiError returns an error consisting of multiple errors on the same logical level. If you provide a MultiError, it will append its errors correctly.

func Newf

func Newf(format string, args ...interface{}) error

Newf creates a new error with the given message. See fmt.Printf and Errorf for formatting. Calls standard errors.Errorf, so "%w" is supported.

func Unwrap

func Unwrap(err error) error

Unwrap calls standard API errors.Unwrap.

Types

type MultiError

type MultiError struct {
	Errors []error
}

MultiError is an implementation of error that consists of arbitrarily many errors on the same logical level.

func (*MultiError) Error

func (e *MultiError) Error() string

Jump to

Keyboard shortcuts

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