errmatch

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2022 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BeCausedBy

func BeCausedBy(expected interface{}) types.GomegaMatcher

BeCausedBy is a robust error matcher that works with a number of error libraries, including Go 1.13 errors, pkg/errors, and hashicorp/multierror. The expected value is used to construct a gomega.MatchError matcher, and then it is used to check one of the following:

  • actual passes MatchError(expected)
  • actual can be unwrapped, and the unwrapped value passes BeCausedBy.
  • pkg/errors.Cause(actual) passes MatchError(expected). This would be hit when you use pkg/errors.Wrap. Note that this only looks for the 'cause' error, and would not work to match error messages of intermediate wrapped errors. However, you can use BeCausedBy("outer: inner") (or MatchError) to match the full message.
  • any of ((*multierror.Error)actual).Errors passes BeCausedBy. That is, if you use errors.Wrap in conjunction with multierror, the individual errors in multierror are unwrapped with errors.Cause.

If all of those do not pass, BeCausedBy fails.

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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