wraperr

package
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2021 License: Apache-2.0 Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type WrapErr

type WrapErr struct {
	Err  error
	Wrap error
}

WrapErr wraps an underlying error with another error

Example usage:

var ErrLimit = errors.New("Limit reached")
...
func someFunc() error {
  return wrapper.WrapErr{Err: fmt.Errorf("Limit %d reached on %s", limit, instance), Wrap: ErrLimit}
}
...
if errors.Is(err, ErrLimit) { ... }

This makes it easier to include a custom error message while also allowing

func New

func New(err, wrap error) WrapErr

New returns a new WrapErr

func (WrapErr) Error

func (e WrapErr) Error() string

func (WrapErr) Unwrap

func (e WrapErr) Unwrap() error

Jump to

Keyboard shortcuts

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