match

package
v0.8.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type All

type All []ErrorMatcher

All matches an error if all of the underlying matchers match it.

func (All) MatchError

func (m All) MatchError(err error) bool

MatchError calls underlying matchers with err. If all of them matches err it returns true, otherwise false.

type Any

type Any []ErrorMatcher

Any matches an error if any of the underlying matchers match it.

func (Any) MatchError

func (m Any) MatchError(err error) bool

MatchError calls underlying matchers with err. If any of them matches err it returns true, otherwise false.

type ErrorMatcher

type ErrorMatcher interface {
	// MatchError checks if err matches a certain condition.
	MatchError(err error) bool
}

ErrorMatcher checks if an error matches a certain condition.

func As

func As(target interface{}) ErrorMatcher

As returns an error matcher that determines matching by calling errors.As.

func Is

func Is(target error) ErrorMatcher

Is returns an error matcher that determines matching by calling errors.Is.

type ErrorMatcherFunc added in v0.5.2

type ErrorMatcherFunc func(err error) bool

ErrorMatcherFunc turns a plain function into an ErrorMatcher if it's definition matches the interface.

func (ErrorMatcherFunc) MatchError added in v0.5.2

func (fn ErrorMatcherFunc) MatchError(err error) bool

MatchError calls the underlying function to check if err matches a certain condition.

Jump to

Keyboard shortcuts

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